您的位置:首页 > 运维架构 > Shell

shell脚本,对指定目录下C文件,替换和删除字符串

2018-03-12 09:52 736 查看
#!/bin/sh
echo -e "file patch"
read file_path

find $file_path -name "*.c" > path.txt
dos2unix -q path.txt
line_number=$(cat path.txt | wc-l)
for(i=1;i<$line_number;i++)
{
    sed_para="$(i)p"

    cmd="sed -n "$sed_para" path.txt"

    scm_file=$($cmd)

    sed -i '/xxxxx/d' $scm_file #delete line include xxxxx

    sed -i '/xxxxx/yyyyy/d' $scm_file #replace xxxxx to yyyyy

}
rm -f path_txt
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息