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
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
相关文章推荐
- shell脚本:以一定规律替换某个目录下某些文件中的某个字符串
- shell 脚本 打印指定目录下包含某些字符串的文件
- shell删除当前目录及递归目录下文件指定字符串
- shell脚本:以一定规律替换某个目录下某些文件中的某个字符串
- shell删除当前目录及递归目录下文件指定字符串
- Shell脚本执行hive语句 | hive以日期建立分区表 | linux schedule程序 | sed替换文件字符串 | shell判断hdfs文件目录是否存在
- 涛哥的Python脚本工具箱之批量替换目录所有指定扩展名的文件中的指定字符串
- 使用shell命令sed将指定目录下的所有文件中指定的字符串替换成指定的字符串
- shell脚本删除指定目录下超过指定时间的文件
- 根据字段状态删除指定目录文件的shell脚本
- 使用sh脚本如何替换指定目录下所有文件中的指定字符串
- shell脚本删除目录下的指定文件
- shell脚本中调用vim 替换指定路径下文件中的字符串
- shell脚本删除目录下的指定文件
- Linux监控系统磁盘使用比例,当使用率达到指定比例,删除指定目录下的所有文件的shell脚本
- shell 脚本替换文件中某个字符串
- 查找和替换指定目录下所有文件中字符串(use sed and grep)
- shell 脚本替换文件中某个字符串
- 在指定目录查找指定后缀文件的shell脚本代码
- Shell脚本统计指定目录下子目录中的文件个数