Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Retrieve the record using 2,2 lines and display the ouput in columnwise

Tags
shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 06-23-2011
Retrieve the record using 2,2 lines and display the ouput in columnwise

This is my file
-------------
Code:
Using index 8 for dump of table abd_det. (6101)
Dumped 0 records. (13932)
Using index 10 for dump of table abscc_det. (6101)
Dumped 0 records. (13932)
Using index 14 for dump of table absc_det. (6101)
Dumped 254365 records. (13932)
Using index 16 for dump of table absd_det. (6101)
Dumped 0 records. (13932)
Using index 18 for dump of table absi_mstr. (6101)
Dumped 0 records. (13932)
Using index 19 for dump of table absl_det. (6101)
Dumped 0 records. (13932)
Using index 21 for dump of table absr_det. (6101)
Dumped 66359 records. (13932)

I want the output like this:
-------------------------
Code:
abd_det - 0
abscc_det-0
absc_det-254365
absd_det-0
absi_mstr-0
absl_det-0
absr_det-66359


Last edited by Franklin52; 06-23-2011 at 03:53 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 06-23-2011
Code:
perl -ln0e 'while (/table (\w+).*\nDumped (\d+)/g){print "$1 - $2"}' file

# 3  
Old 06-23-2011
Code:
 
nawk ' /Using index/{printf ("%s - ",$8);getline;print $2}' test
abd_det. - 0
abscc_det. - 0
absc_det. - 254365
absd_det. - 0
absi_mstr. - 0
absl_det. - 0
absr_det. - 66359

# 4  
Old 06-23-2011
Another one:
Code:
awk -F"[. ]" '/Using/{printf $(NF-2) " - "} /Dumped/{print $2}' file

# 5  
Old 06-23-2011
Code:
awk -F "[. ]" '{printf (NR%2?$(NF-2):"-" $2 RS)}' infile

# 6  
Old 06-23-2011
Sed way..
Code:
sed '/_/{N;s/.* \(.*\)\. [^ ]* \([0-9]*\) .*/\1-\2/}' inputfile > outfile

# 7  
Old 06-23-2011
Lot of Thanks for all the inputs.
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk command to retrieve record 23 and 89 from UNIX file rakeshp Homework & Coursework Questions 6 09-09-2017 12:31 AM
awk command to retrieve record 23 and 89 from UNIX file rakeshp UNIX for Beginners Questions & Answers 1 09-01-2017 03:02 PM
Help with keep the first record display perl_beginner Shell Programming and Scripting 2 07-09-2013 04:31 AM
how to retrieve lines that the first 4 columns have different values new2awkin2011 Shell Programming and Scripting 15 08-17-2011 11:50 AM
Retrieve lines from a file in a given date range oopcho Shell Programming and Scripting 5 05-09-2011 11:03 PM
have to retrieve the distinct values (not duplicate) from 2nd column and display shirdi Shell Programming and Scripting 16 03-13-2010 08:02 AM
How can i retrieve some specific lines from a file using C vigneshinbox Programming 3 04-03-2009 05:44 PM
retrieve lines using sed, grep or awk learning_linux UNIX for Dummies Questions & Answers 3 03-25-2009 05:51 AM
Script to display record spanning over multiple lines Ujan Shell Programming and Scripting 2 03-05-2009 05:06 AM
retrieve lines that match a pattern fadista UNIX for Dummies Questions & Answers 2 12-10-2008 03:40 AM


All times are GMT -4. The time now is 06:00 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password