Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a file full of filepaths relative to its own path:

./Talent/152/Resume/a file name.pdf
./Talent/153/Resume/some file name.pdf
./Talent/154/Resume/yet another file name.pdf
... and so on ...

What would be the appropriate shell command to go through each line in this file and remove it?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted
xargs -d '\n' rm < listoffiles.txt
share|improve this answer
    
+1 very handy to know... i was unaware of the -d option for xargs... –  cpbills Jun 6 '10 at 0:53
add comment
xargs -I{} --arg-file=file rm "{}"

or

xargs -I{} -a file rm "{}"

The quotes protect filenames with spaces.

share|improve this answer
add comment

If you are in a Bash shell you can do :

find ./Talent/*/Resume/* -exec rm {} \;

or if you want to delete the files older than 7 day you can add -mtime param like this :

find ./Talent/*/Resume/* -mtime +7 -exec rm {} \;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.