我正在努力使用IF语句。
目录传递到脚本,该目录(包含任意数量的子文件夹)将在其中包含.txt
文件,或者.tmp
在其中包含文件,而我的最终目标是将所有.tmp
文件复制到一个文件夹中,然后将.txt
文件复制到另一个文件夹中。
目前有:
shopt -s nullglob
if [[ -n $(echo *.txt) ]]; then
elif [[ -n $(echo *.tmp) ]]; then
else
echo "nothing Found"
fi
但是它不检查子目录。缺少什么吗?
您将要使用以下find
命令:
find "$start_dir" -type f -name '*.txt' -exec cp -t "$txt_destination" '{}' +
find "$start_dir" -type f -name '*.tmp' -exec cp -t "$tmp_destination" '{}' +
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句