且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Shell命令/脚本删除名称在文本文件中的文件

更新时间:2023-12-05 20:31:28

 而读取-r文件名;做
rm $ filename
完成< list.txt

  rm $(< list.txt)
$ p如果参数太多,$ p>

将会失败。



我认为应该可以:

  xargs -a list.txt -d'\n'rm 


I have a list of files in a .txt file (say list.txt). I want to delete the files in that list. I haven't done scripting before. Could some give the shell script/command I can use. I have bash shell.

while read -r filename; do
  rm "$filename"
done <list.txt

is slow.

rm $(<list.txt)

will fail if there are too many arguments.

I think it should work:

xargs -a list.txt -d'\n' rm