Makefile Shell 脚本;sed命令

1. 在Makefile中想使用shell脚本,需要添加"@"符号,例如:

      @if [ -d xxx ]; then                        //-d 判断是否存在,在shell中,用[]号代替括号

          rm -rf xxx;  

      fi;

      @cp -fv  xxx  xxxx     //-f 删除已经存在的目标文件而不提示  -v  cp命令将告诉用户正在做什么

      例:  cp -fv temp temp2

             显示: 'temp'  ->  'temp2'

     //查找所有的KO文件,并拷贝

     @find  sor_dir  -name "*.ko" -exec  sudo cp -vf '{}'  des_dir  ';'

      @echo "OK."

2. sed 是linux下文本处理工具

   格式:sed 's/要替换的字符串/新的字符串/g'   (要替换的字符串可以用正则表达式)

   //例如将某一个文件xxxx中相关字符串替换

   @cat  xxxx  | sed "s/0000/9999/g" | sed "s///#define 7777/#define 8888/g" > xxxx2

原文地址:https://www.cnblogs.com/maxpak/p/4596919.html