Use*_*ser 3 linux bash shell sh
我有一个a.txt包含文件列表的文本文件:
photo/a.jpg
photo/b.jpg
photo/c.jpg
etc
Run Code Online (Sandbox Code Playgroud)
我想获取不存在的文件的列表。
您可以使用:
xargs -I % bash -c '[[ ! -e $1 ]] && echo "$1"' _ % < a.txt > b.txt
Run Code Online (Sandbox Code Playgroud)
xargs将运行bash -c在每一行a.txt。[[ ! -e $1 ]]将检查每个条目是否不存在。