Unix: How to delete files listed in a file

后端 未结 13 1595
遥遥无期
遥遥无期 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 07:12

    Here's another looping example. This one also contains an 'if-statement' as an example of checking to see if the entry is a 'file' (or a 'directory' for example):

    for f in $(cat 1.txt); do if [ -f $f ]; then rm $f; fi; done
    

提交回复
热议问题