bash常用实例

### 获得当前脚本路径

$(dirname -- $(readlink -f -- "$0"))



### 替换NTP服务器IP
sed -r '/ntpdate/s/([0-9]+\.){3}[0-9]+/192.168.1.1/g' /var/spool/cron/root

### 星号转义输出
tt="echo '* */1 * * * root /usr/sbin/ntpdate -u 10.60.145.200;/sbin/clock -w'"
echo -e "$tt" #使用引号第三个星号会列出本地文件列表

你可能感兴趣的:(bash)