Nov 24, 2004 #1 fabien Technical User Joined Sep 25, 2001 Messages 299 Location AU Hi! I have a file which contains a list of files to be deleted. What simple command should I use with that file as input to delete all the files listed in one go? I tried rm -f `cat /tmp/filename` but that does not work Many thanks,
Hi! I have a file which contains a list of files to be deleted. What simple command should I use with that file as input to delete all the files listed in one go? I tried rm -f `cat /tmp/filename` but that does not work Many thanks,
Nov 24, 2004 1 #2 columb IS-IT--Management Joined Feb 5, 2004 Messages 1,231 Location EU Echoing usually replaces CR with space so try Code: rm -f $(echo $(cat /tmp/filename)) Columb Healy Living with a seeker after the truth is infinitely preferable to living with one who thinks they've found it. Upvote 0 Downvote
Echoing usually replaces CR with space so try Code: rm -f $(echo $(cat /tmp/filename)) Columb Healy Living with a seeker after the truth is infinitely preferable to living with one who thinks they've found it.
Nov 24, 2004 Thread starter #3 fabien Technical User Joined Sep 25, 2001 Messages 299 Location AU this does not work I get a variable syntax error Upvote 0 Downvote
Nov 24, 2004 #4 PHV MIS Joined Nov 8, 2002 Messages 53,708 Location FR but that does not work Can you please be more descriptive ? Some guesses: rm -f $(</tmp/filename) while read f do rm -f "$f" done</tmp/filename Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244 Upvote 0 Downvote
but that does not work Can you please be more descriptive ? Some guesses: rm -f $(</tmp/filename) while read f do rm -f "$f" done</tmp/filename Hope This Helps, PH. Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
Nov 24, 2004 #5 hoinz MIS Joined Jan 29, 2004 Messages 944 Location DE fabien, I remember having successfully done it the way you describe. Do you get any error messages? Do you use absolute or relative path names? An alternative would be: for i in `cat /tmp/filename` do rm $i done hth Upvote 0 Downvote
fabien, I remember having successfully done it the way you describe. Do you get any error messages? Do you use absolute or relative path names? An alternative would be: for i in `cat /tmp/filename` do rm $i done hth
Nov 24, 2004 #6 columb IS-IT--Management Joined Feb 5, 2004 Messages 1,231 Location EU I've tested my version Code: rm -f $(echo $(cat /tmp/filename)) and it works a treat using ksh on AIX 5.1 What OS and shell are you using? Columb Healy Living with a seeker after the truth is infinitely preferable to living with one who thinks they've found it. Upvote 0 Downvote
I've tested my version Code: rm -f $(echo $(cat /tmp/filename)) and it works a treat using ksh on AIX 5.1 What OS and shell are you using? Columb Healy Living with a seeker after the truth is infinitely preferable to living with one who thinks they've found it.
Nov 24, 2004 #7 hoinz MIS Joined Jan 29, 2004 Messages 944 Location DE another idea: Could the problem be inside your file /tmp/filename ? filenames containing wildcards, special characters, blanks and the like? hth Upvote 0 Downvote
another idea: Could the problem be inside your file /tmp/filename ? filenames containing wildcards, special characters, blanks and the like? hth
Nov 24, 2004 Thread starter #8 fabien Technical User Joined Sep 25, 2001 Messages 299 Location AU Columb, I tried ksh on Sun Solaris and it worked like you said. I was using csh. What would be the csh version then? Cheers! Upvote 0 Downvote
Columb, I tried ksh on Sun Solaris and it worked like you said. I was using csh. What would be the csh version then? Cheers!
Nov 24, 2004 #9 hoinz MIS Joined Jan 29, 2004 Messages 944 Location DE $() construct doesn't exit in csh; the backtick equivalent of columb's idea: rm -f `echo \`cat /tmp/filename\`` hth Upvote 0 Downvote
$() construct doesn't exit in csh; the backtick equivalent of columb's idea: rm -f `echo \`cat /tmp/filename\`` hth
Nov 25, 2004 #10 Chacalinc Vendor Joined Sep 2, 2003 Messages 2,043 Location US awk ' { system("rm -f $0") } ' /tmp/filename Upvote 0 Downvote