#!/bin/bash
cd //home/linhaot/sharing/RK/project
a=0
find . -type f -name "Makefile"|while read LINE
do
cd //home/linhaot/sharing/RK/project
cd ${LINE%%Makefile*}
echo ${LINE%%Makefile*}
if [ "$(ls|grep "change")" = "change_time.txt" ]
then
old_time=$(cat change_time.txt)
echo "oldtime=$old_time"
new_time=$(stat -c "%y" Makefile)
echo "newtime=$new_timen"
if [ "echo $old_time" != "echo $new_time" ]
then
cd //home/linhaot/sharing/RK/project
./build.sh | tee /home/linhaot/sharing/rk_test.txt
cd ${LINE%%Makefile*}
stat -c "%y" Makefile > change_time.txt
fi
else
cd ${LINE%%Makefile*}
touch change_time.txt
stat -c "%y" Makefile > change_time.txt
fi
done
cd //home/linhaot/sharing
grep -n "(RK_APP_TYPE)=" rk_test.txt
grep -n "app_src" rk_test.txt
现在是要改不同路径下的其他makefile,之前写的程序只针对特定makefile,所以为了简化过程,我对之前的代码进行一个改进。
注意点 ①find函数-找到当前目录下所有makefile的路径,包括子目录的linux,检测文件是否有更新_如来fo的博客-CSDN博客
find . -type f -name "Makefile"②字符串操作-截取得到路径中不包含makefile的前半部分
${LINE%%Makefile*}
③遍历各个路径-while 语句linux中字符串截取的八种方法_涤生大数据的博客-CSDN博客_linux截取字符串中的一部分
这里将find读出的内容用 “|”输出到while然后对一个个路径进行操作。
find . -type f -name "Makefile"|while read LINE do done④if语句做判断的时候
要记得什么是整数操作的,什么是字符串操作的
⑤touch语句创建txt文件touch change_time.txt
若是用vim会报错



