Operating System - HP-UX
1833996 Members
2367 Online
110063 Solutions
New Discussion

Re: DELETING FILES THAT ARE CONTAINED IN A FILE

 
SOLVED
Go to solution
Kurt Greener
Occasional Contributor

DELETING FILES THAT ARE CONTAINED IN A FILE

I am having a little trouble figuring out how to delete files from a list that is contained in a file. I have created a script to pull the list of files off the tape backup, clean up the file using sed and grep, then send the output to a file.
4 REPLIES 4
Brian M. Fisher
Honored Contributor
Solution

Re: DELETING FILES THAT ARE CONTAINED IN A FILE

Try the following script:

cat filelist | while read file
do
rm -i $file
done


Brian
<*(((>< er
Perception IS Reality
Kurt Greener
Occasional Contributor

Re: DELETING FILES THAT ARE CONTAINED IN A FILE

Thanks Brian... I changed the -i to a -f to allow the "larger" script to process fully.
Robert Haney
New Member

Re: DELETING FILES THAT ARE CONTAINED IN A FILE

In either the Korn or POSIX shells, use:

rm -i $(< filelist)
The whole of man is to obey God.
keh
Occasional Contributor

Re: DELETING FILES THAT ARE CONTAINED IN A FILE

I got some ideas
1)awk '{print "rm $0"}' file_1 > file_2
where:
1.1)file_1 contain files you want to delete
1.2)file_2 contain commands for rm files

2)cat file_1 | xargs -i -t rm {}
2.1)file_1 contain full path to files you want to delete
keh