Computing.Net > Forums > Unix > Delete files from textfile listing?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Delete files from textfile listing?

Reply to Message Icon

Name: AugustineAndrew
Date: November 17, 2005 at 01:37:37 Pacific
OS: SunOS 5.6
CPU/Ram: 64MB
Comment:

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




Sponsored Link
Ads by Google

Response Number 1
Name: koala95
Date: November 17, 2005 at 02:51:35 Pacific
Reply:

you can do:
for i in `cat logfile.log`
do
rm $i
done


My Email:old_bear40@yahoo.com


0

Response Number 2
Name: nails
Date: November 17, 2005 at 07:52:57 Pacific
Reply:

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


0

Response Number 3
Name: AugustineAndrew
Date: November 21, 2005 at 19:16:41 Pacific
Reply:

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} $i

Please kindly advice. Thanks a million!

Best Regards,

Andrew


0

Response Number 4
Name: AugustineAndrew
Date: November 21, 2005 at 19:21:20 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Delete files from textfile listing?

deleting files from a tarfile www.computing.net/answers/unix/deleting-files-from-a-tarfile/3313.html

Remove files from list www.computing.net/answers/unix/remove-files-from-list/4759.html

deleting files older than 2 days www.computing.net/answers/unix/deleting-files-older-than-2-days/4394.html