参考:https://www.cnblogs.com/liyuchuan/p/10756066.html
目录结构:
/data/dir1
subdir/
subfile
/data/dir2
subdir/
subfile
目的是为了判断2个相同结构的文件夹中,有哪些文件的内容是不一样的。
#!/bin/bash read_dir(){ for file in `ls -a $1` do if [ -d $1"/"$file ] then if [[ $file != ‘.‘ && $file != ‘..‘ ]] then read_dir $1"/"$file fi else diff $1"/"$file $(echo $1 | sed -e s‘/dir1/dir2/‘)"/"${file} 1>/dev/null 2>&1 && result=0 || result=1 if [ "$result" == 1 ];then echo "$1"/"$file is diff" >> result.log fi fi done } read_dir /data/dir1
原文:https://www.cnblogs.com/t-road/p/11418436.html