The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 02-11-2009
bjawasa bjawasa is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 3
script to capture content of deleted file

I need to capture the content of a file before its being deleted. This file gets deleted immediately after it is created.

I use the below shell command in the command prompt, but I'm not getting the desired result.

bash-3.00# while true; do cat file* > tempfile; done;

What I'm trying here is to capture the content of "file*" and output it to tempfile. The content of "file*" gets overwritten in the process and I need to see the latest content.

If I don't try to output it in 'tempfile' I could see the content of the file in the command line -> bash-3.00# while true; do cat file*; done;

Any idea if this can be done in a better way?