mac shell

mac shell

mac 中sed命令的参数格式和普通Linux中是不同的

mac:

find ./ -type f -iname "*.css" |xargs sed -i '' 's/dist\///'

    find ./ -type f -iname "*.js" |xargs sed -i '' '/^[^#]*alert(/d'

sed参数-i后面需要加上一个空字符串

cent os中:

find ./ -type f -iname "*.css" |xargs sed -i 's/dist\///'

    find ./ -type f -iname "*.js" |xargs sed -i '/^[^#]*alert(/d'

判断是否是mac:

#操作系统类型
os_type=`uname -s`
if [ x"$os_type" = x"Darwin" ];then
find ./ -type f -iname "*.css" |xargs sed -i '' 's/dist\///'
find ./ -type f -iname "*.js" |xargs sed -i '' '/^[^#]*alert(/d'
else
find ./ -type f -iname "*.css" |xargs sed -i 's/dist\///'
find ./ -type f -iname "*.js" |xargs sed -i '/^[^#]*alert(/d'
fi

# 批量替换文件中的内容
 grep "sumk-http-demo" -rl .|xargs -I {}  sed -i '' 's/sumk-http-demo/sumk-http-demo2/g'  {}

相关推荐