shell脚本——比较不同目录下所有文件

时间:2023-01-07 14:30:51
#!/bin/bash

#遍历目录函数
list_alldir(){
    for road in `ls -a $1`
    do
        if [ x"$road" != x"." -a x"$road" != x".." ];then
            if [ -d "$1/$road" ];then
                echo "$1/$road"
                list_alldir "$1/$road"
            fi
        fi
    done
}

echo "输入文件A的根目录:"
read path_A
list_alldir $path_A >Adir.txt

echo "输入文件B的根目录:"
read path_B
list_alldir $path_B >Bdir.txt


#stat -c %s $path_A/*
#stat -c %s $path_B/*

ls -nRstk $path_A/*
ls -nRstk $path_B/*