Capture only the new lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capture only the new lines
# 1  
Old 05-03-2009
Capture only the new lines

Whenever job run i need to capture only the news in growing file(audit file)?
How can we achieve this?
# 2  
Old 05-03-2009
# 3  
Old 05-03-2009
tail cmd will give only last given number of lines. I need to get only newlines which is appended in growing files (a.log).
For every run a.ksh which will produce a.log. For example if a.ksh is successful run will then a.log will return 3 rows but if it is unsuccessful run then 2 or any counts of row returned in log file.How do we capture only the latest row returned in a.log

1st run a.ksh
----------
cat a.log
process start
123 counts loaded
process end

2nd run a.ksh
------------
cat a.log
process start
123 counts loaded
process end
process start
149 counts loaded
process end
(here i need to capture last 3 line like tail -3 filename)

3rdrun a.ksh (unsuccessful run)
-----------
cat a.log
process start
123 counts loaded
process end
process start
149 counts loaded
process end
process start
process end
(here i need to capture last two lines)


One way of doing is like taking diff in a.log between before and after run will return the latest line.
Is any other simple cmd to get the newline in audit file?
# 4  
Old 05-03-2009
Quote:
Originally Posted by ford2020
tail cmd will give only last given number of lines. I need to get only newlines which is appended in growing files
Quote:
-f output appended data as the file grows
(extract from man tail)
# 5  
Old 05-03-2009
Code:
tail -f logfile > newfile

you can run that in the background. But make sure you stop it at some point of time.


cheers,
Devaraj Takhellambam
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

TCL script to capture range of lines and create two independent variables

Hi I am having a code as stated below module abcd( a , b , c ,da , fa, na , ta , ma , ra , ta, la , pa ); input a , b, da ,fa , na , ta , ma; output c , ra ,ta , la ,pa ; wire a , b , da , fa ,na , ta , ma; // MBIST Structures... (1 Reply)
Discussion started by: kshitij
1 Replies

2. Shell Programming and Scripting

awk to capture lines that meet either condition

I am trying to modify and understand an awk written by @Scrutinizer The below awk will filter a list of 30,000 lines in the tab-delimited file. What I am having trouble with is adding a condition to SVTYPE=CNV that will only print that line if CI=,0.95: portion in blue in file is <1.9. The... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. UNIX for Dummies Questions & Answers

Capture Multiple Lines Into Variable As Of Standard Output

Hello All, I have the below script and output. cat test.sh #!/bin/bash -x logit() { echo " - ${*}" > ${LOG_FILE} } LOG_FILE=/home/infrmtca/bin/findtest.log VAR=`find . -type f -name "*sql"` logit $VAR Output: cat /home/infrmtca/bin/findtest.log -... (9 Replies)
Discussion started by: Ariean
9 Replies

4. Shell Programming and Scripting

Sed capture help

Hi, I'm a newbie to sed and learning about sed 1 liners and captures. I was wondering if someone could help me with the code below: http://i51.tinypic.com/2eg4kdd.png So that's taking a URL and splitting it into URL,TLD & Filename. Any help on how I can do this is much appreciated. ... (6 Replies)
Discussion started by: r4v3n
6 Replies

5. Shell Programming and Scripting

How do I capture multiple lines of the status output of a command?

I need to know what the upload speed of an Internet connection. I thought the easiest way to do this would be to transfer a file via FTP to my server using the command: sh-3.2$ ftp -u ftp://username:password@computerdomain/directory/ file_to_be_uploaded Note: My environment allows me to issue... (2 Replies)
Discussion started by: zzz1528
2 Replies

6. Shell Programming and Scripting

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 - -----------". I want this script to capture the line starting from "begin ------... (0 Replies)
Discussion started by: fara_aris
0 Replies

7. UNIX for Dummies Questions & Answers

How to count lines - ignoring blank lines and commented lines

What is the command to count lines in a files, but ignore blank lines and commented lines? I have a file with 4 sections in it, and I want each section to be counted, not including the blank lines and comments... and then totalled at the end. Here is an example of what I would like my... (6 Replies)
Discussion started by: kthatch
6 Replies

8. UNIX for Advanced & Expert Users

Capture Value from file

I have a file in the following Format Fundid: 100-BankA AccountNumber Balance 1 200 2 300 3 400 FundId:123321-BankB AccountNumber Balance 1 200 3 100 ........... I can have N number of funds. (1 Reply)
Discussion started by: kris01752
1 Replies

9. AIX

Capture IP Adress

hello I need for a script to capture the ip address from the connected user. I have 5 logical partitions. With "who", i have the ip adress, but only for 2 servers. Do you know another command to know the ip address of connected clients ? thank you (14 Replies)
Discussion started by: pascalbout
14 Replies

10. Shell Programming and Scripting

Capture lines based on keywords

Hello everyone, I am trying to write a script that will capture few lines from a text file based on 2 keywords in the first line and 1 keyword in the last one. It could also be based on the first line only + the folllowing 3 lines. Could some one help or give directions. Thanks. (4 Replies)
Discussion started by: nimo
4 Replies
Login or Register to Ask a Question