Script to capture new lines in a file and copy it to new file


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to capture new lines in a file and copy it to new file
# 1  
Script to capture new lines in a file and copy it to new file

Hi All,
I have a file that gives me new line/output every 5 minutes. I need to create a script that capture new line/output besides "IN CRON_STATUS", in this case the new output is "begin ------ cron_status.sh - [started] -----------".

I want this script to capture the line starting from "begin ------ cron_status.sh - [started] -----------" until it reads "IN CRON_STATUS" again. If the script notice the "IN CRON_STATUS", it will stop capturing and direct the output to a different file name and rename it to the original name but with timestamp.

Sample;
---------05/21/08-05:00:00-------- IN CRON_STATUS -----------------------------------
---------05/21/08-05:00:00-------- IN CRON_STATUS -----------------------------------
---------05/21/08-05:05:00-------- IN CRON_STATUS -----------------------------------
---------05/21/08-05:05:00-------- IN CRON_STATUS -----------------------------------
---------05/21/08-05:15:00-------- IN CRON_STATUS -----------------------------------
--------------------------------------- begin ------ cron_status.sh - [started] -----------

- Message Started found in /RCEBTM_appli/RCEBMA/mbox/hubftpa
- Starting Tuxedo
---------05/21/08-05:15:00-------- IN CRON_STATUS -----------------------------------
---[CRON]---05/21/08-05:15:00-------- Message Started found in /RCEBTM_appli/RCEBMA/log
---[CRON]---05/21/08-05:15:00-------- Starting RCE
---[CRON]---05/21/08-05:15:00-------- Starting RCE servers ...
XXXXX.XXXXX!BBL.21394: 052108: TUXEDO Version 6.5 HP-UX B.11.00 U XXXX/XXXXXXX unlimited-user license.
- sending file with ftp: success
---------05/21/08-19:55:00-------- IN CRON_STATUS -----------------------------------
---------05/21/08-19:55:00-------- IN CRON_STATUS -----------------------------------
---------05/21/08-20:00:00-------- IN CRON_STATUS -----------------------------------


Please advise.

Thank you in advance.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #847
Difficulty: Medium
Proximity marketing is the localized wireless distribution of advertising content associated with a particular place.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy lines from x to y to another file

OS : RHEL 7.2 Shell : bash I have a file which has lines like below I want to copy from 2nd line to the 6th line and copy(redirect) those lines to another file. $ cat patterns.txt hello world hello asia hello europe hello africa hello america hello antartica hello... (9 Replies)
Discussion started by: omega3
9 Replies

2. UNIX for Beginners Questions & Answers

How to copy only some lines from very big file?

Dear all, I have stuck with this problem for some days. I have a very big file, this file can not open by vi command. There are 200 loops in this file, in each loop will have one line like this: GWA quasiparticle energy with Z factor (eV) And I need 98 lines next after this line. Is... (6 Replies)
Discussion started by: phamnu
6 Replies

3. Shell Programming and Scripting

How to copy lines that starts with either 3 or 4 into new file?

Hi Guys, I have an awk script that would search the input file for line that starts with a number 3 and copies into a new text file. I want to extend this script to find the lines that either starts with 3 or a or b and copy all those lines into the new file. Here is what I have so far:... (1 Reply)
Discussion started by: Amith821
1 Replies

4. Shell Programming and Scripting

copy range of lines in a file based on keywords from another file

Hi Guys, I have the following problem. I have original file (org.txt) that looks like this module v_1(.....) //arbitrary number of text lines endmodule module v_2(....) //arbitrary number of text lines endmodule module v_3(...) //arbitrary number of text lines endmodule module... (6 Replies)
Discussion started by: kaaliakahn
6 Replies

5. Shell Programming and Scripting

set -x within script and capture as a file

Okay, I've been working on a script for providing information on the progress of a backgrounded ditto command. Thanks to google and a lot of searching I've resolved all but one very odd error. At this point, I want to use xtrace (set -x) to try to uncover the issue. I have found several examples... (2 Replies)
Discussion started by: reid
2 Replies

6. Shell Programming and Scripting

looking for help on script to capture file permission.

Hi Guys, I'm a DBA and need help on shell scripting. My Oracle Database is sitting on HP-UX machine. Anyone has a script that can spool out permission of all oracle binary files in the below directory: /opt/ora10g/oracle/ Format to be spooled out : chmod <exisiting permission> filename... (10 Replies)
Discussion started by: ciaciachew
10 Replies

7. Shell Programming and Scripting

Solaris KSH shell script to copy all lines from one file to another

Hello, more of a windows wscript guy. However I took a new position that requires me to support some solaris servers. So... issue is that I need to copy all lines from a file to a temporary file and then copy them back into the original file starting at line 1. Reason I need to do this is... (5 Replies)
Discussion started by: ZigZaggin
5 Replies

8. Shell Programming and Scripting

Grep: Copy all lines from log file into new file

Hello everyone. I have a log file that contains multiple domains: www.thisdomain.com agent.thisdomain.com that.thisdomain.com I need to copy all of the lines that contain "www.thisdomain.com" from the log and output them into a new file. I've tried everything with little luck. Please help... (3 Replies)
Discussion started by: aberli
3 Replies

9. UNIX for Dummies Questions & Answers

copy lines from opne file to another

Hi all, I'm new to shell scripting. I want to copy the first N lines from a file to another file. Can someone please tell me how this can be done. Thanks Himi (2 Replies)
Discussion started by: HIMANI
2 Replies

10. Shell Programming and Scripting

Copy only the initial 10 lines from a file to another

Hi all, I'm new to shell scripting. I want to copy initial few lines(say first 10 lines) from a file to another file. There is no "head" command in our embedded system. sed & awk is there which I believe will do that, but I dont know how to. This is linux 2.6 (embedded) So please help me.... (5 Replies)
Discussion started by: jockey007
5 Replies

Featured Tech Videos