我試圖編寫一個腳本來讀取一個帶有文件名的文件,並輸出是否在目錄中找到這些文件。使用bash數組循環查找列表中的文件
按道理我想它是這樣的:
$filelist = prompt for file with filenames
$directory = prompt for directory path where find command is performed
new Array[] = read $filelist line by line
for i, i > numberoflines, i++
if find Array[i] in $directory is false
echo "$i not found"
export to result.txt
我一直有一個很難得到猛砸要做到這一點,任何想法?
您可以使用'if [-f「$ dir/$ file」]'來查看'file'是否在'dir'內。 – Bill
在這裏搜索'[bash]找到xargs',你應該找到許多文章給你的想法。祝你好運。 – shellter