嗨我有这个任务,我必须从目标树中搜索一个文件,从声明的目录开始。我有这个代码,但我不确定它是否基本正确,因为我从未使用过bash shell:)
fileName = "sample.txt"
directory = "test/directory";
for var i in $directory/sub1 $directory/sub2 $directory/sub3
if[$fileName]
do
echo: "$filename found"
done
代码更新:
listArr=( $(find "$1" -perm /a+x -type f | sed 's/\.\///g') )
for file in "${listArr[@]}"; do
pathArr=( $(echo "$file" | sed 's/\//\/ /g') )
i=0
for row in "${pathArr[@]}"; do
printf %$(eval echo $i)s | sed 's/ / /g'
echo "$row"
i=$((i + 1))
done
done