Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to delete flat files from home directory.

Status
Not open for further replies.

tekpr00

IS-IT--Management
Jan 22, 2008
186
0
0
CA
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.
 
Something like this?
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top