![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Capture Shell Script Output To A File | rajan_san | Shell Programming and Scripting | 4 | 01-13-2009 01:30 PM |
| Script to capture new lines in a file and copy it to new file | fara_aris | Shell Programming and Scripting | 0 | 05-27-2008 10:11 PM |
| shell script to search content of file with timestamps in the directory | psychobeauty | Shell Programming and Scripting | 10 | 04-21-2008 05:37 AM |
| shell script to edit the content of a file | tiger99 | Shell Programming and Scripting | 3 | 01-31-2008 04:43 AM |
| file content to standard output from a script | bryan | Shell Programming and Scripting | 4 | 06-30-2006 12:48 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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? |
|
||||
|
Thanks Hari for your quick reply. But the command that you suggested appended the tempfile. As I mentioned "file*" is being overwritten and what I need to capture is the latest content of 'file*' before it is deleted, without being appended to tempfile.
The command that I used earlier -> while true; do cat file* > tempfile; done; or while true; do cat file* > tempfile 2>/dev/null; done; doesn't write anything into tempfile. |
|
||||
|
This file (file*) is being created by an application, and the last part of the filename is generated by the application with a random name.
The main intention is to capture the last written data in this file (file*). This file is FTPed to a remote server and immediately after it is FTPed, it is deleted in the Host Server, and I need to capture what data is written just before it got deleted. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|