INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Script to delete flat files from home directory.

Script to delete flat files from home directory.

(OP)
Hello All:

I have a flat file sample_flat.txt and here are the content.
sample.file.dmp.tar
sample.file2.dmp.gz
.
.
sample.filen.dmp.txt

I will like to write a shell script to be able to take one record from the sample_flat.txt, find the file from home directory / downwards and delete it. Grab the second file from sample_flat.txt search for it and delete it. Lastly, list the files from sample _flat.txt that he could not find/delete.

Thanks for you help.
tekpr00.

RE: Script to delete flat files from home directory.

Something like this?

CODE --> bash

while read FILE_NAME; do
   [ -f "/home/downloads/$FILE_NAME" ] && rm "/home/downloads/$FILE_NAME" || echo "$FILE_NAME not found in /home/downloads."
done < sample_flat.txt 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close