Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Dear Gurus,
How do i delete files in a directory, based on a captured text file listing.
E.g.
ls {dir} > logfile.log
rm {files listed in logfile.log}Please kindly advice. Thank you!
Best Regards,
Andrew

Andrew:
First, before you take koala's advice, consider this UUOC link:
http://support.internetconnection.net/DEFINITIONS/Definition_of_UUOC.html
It's more efficient to do something like:
rm `cat logfile.log`
But I prefer using find:
find dir -type f -print|xargs rm

Hi Koala,
Thank you for your suggestion! I greatly appreciate your prompt response.
What i'm trying to perform here is actually deleting files in another machine memory. For example, the command to delete a file in the machine memory is:
mem del -{file_type} {filename}
In my case, i would like to delete only those files in the machine memory, captured in a particular folder.
Hence, am i able to utilize your suggestion to put into use:
ls {dir} > logfile.log
for i in `cat logfile.log`
do
mem del -{file_type} $iPlease kindly advice. Thanks a million!
Best Regards,
Andrew

Hi Nails,
Thank you for your suggestion too!
Can you please kindly explain on your command?find dir -type f -print|xargs rm
I understand {-type f} = Plain File Type,
{-print} = Display out.What is xargs? Please kindly advice. Thanks!
Sorry, i'm rather new to unix scripting.Best Regards,
Andrew

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |