別のファイルでファイル名例外リストを含むファイルを探す

別のファイルでファイル名例外リストを含むファイルを探す

私のディレクトリには10個のファイルがあります。

test1.txt
test2.txt
test3.txt
.
.
test10.txt

除外ファイル名であるexclusion.txtもあり、そのファイル名は次のとおりです。

test1.txt
test2.txt
test3.txt
text4.txt

除外ファイルからファイル名を除いて結果を提供する find コマンドが必要です。

test5.txt
test6.txt
test7.txt
text8.txt
test9.txt
text10.txt

ベストアンサー1

for file in *.txt;do grep ${file} exclude.txt >/dev/null;r=${?}; if [ $r -ne 0 ]; then echo ${file};fi;done| grep -v exclude.txt

Except.txtが同じディレクトリにない場合は、パイプの後のgrep最後のコマンドを省略できます。|

おすすめ記事