Results 1 to 3 of 3
I am writing a script which will need to read a list congaing files and directories, and delete them. Any advice?
I'm actually stuck on the first step, how do ...
- 11-10-2009 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 10
shell script that deletes files found in a list
I am writing a script which will need to read a list congaing files and directories, and delete them. Any advice?
I'm actually stuck on the first step, how do I read a list? I can choose the deliminator the list will use, so probably comma (,)
- 11-11-2009 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
if you use newline \n as the list delimiter--
/dir1/file1
/dir2/file2
like that, then something like this should work
for i in `cat list`
do
rm $i
donethe sun is new every day (heraclitus)
- 11-12-2009 #3Linux User
- Join Date
- Aug 2006
- Posts
- 458
change IFS to cater for files with spaces when using for loop and cat like that, otherwise, just use while read loop
Code:while read -r line do rm -i "$line" done < "file"


Reply With Quote