Unix: How to delete files listed in a file

后端 未结 13 1651
遥遥无期
遥遥无期 2020-12-04 06:31

I have a long text file with list of file masks I want to delete

Example:

/tmp/aaa.jpg
/var/www1/*
/var/www/qwerty.php

I need delet

13条回答
  •  没有蜡笔的小新
    2020-12-04 06:56

    In this particular case, due to the dangers cited in other answers, I would

    1. Edit in e.g. Vim and :%s/\s/\\\0/g, escaping all space characters with a backslash.

    2. Then :%s/^/rm -rf /, prepending the command. With -r you don't have to worry to have directories listed after the files contained therein, and with -f it won't complain due to missing files or duplicate entries.

    3. Run all the commands: $ source 1.txt

提交回复
热议问题