Shell command/script to delete files whose names are in a text file

后端 未结 6 1975
醉酒成梦
醉酒成梦 2020-12-24 04:00

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 c

6条回答
  •  -上瘾入骨i
    2020-12-24 04:10

    If the file names have spaces in them, none of the other answers will work; they'll treat each word as a separate file name. Assuming the list of files is in list.txt, this will always work:

    while read name; do
      rm "$name"
    done < list.txt
    

提交回复
热议问题