Grab data within a table in a long log file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grab data within a table in a long log file.
# 1  
Old 02-01-2013
Grab data within a table in a long log file.

in my file which is a rather long log file it contains many text and tables and there is one table with 15 columns and I am interested to read in the value in column6 and its corresponding value in column2. Trouble is I do not know how to script it as the line number various between different log file and column 1 is different in all the lines within that table so there is nothing to match. Can anyone tell me how I could write this script?
# 2  
Old 02-01-2013
I don't think you are gonna get some assistance unless you post a representative sample content of your file and desired output.
# 3  
Old 02-01-2013
ok if in my log file

there is a table somewhere in that file (amongst plenty other text and tables) that begins like

Code:
Table title
==========
line of text

line of text

line of text
$$
column1 column2 column3 column4 column5 column6 etc etc etc
1
2
3
4
.
.
.
.
etc

I want to write a script that if the value on column 6 is greater than say, 2, then return the corresponding value on column 2 on the same line.

I hope that makes it clear.

Last edited by Scott; 02-02-2013 at 03:57 AM.. Reason: Fixed code tags
# 4  
Old 02-01-2013
Basically
Code:
awk '$6>2{print $2}' yourfile

May need some tweak depending on the formatting of yourfile
# 5  
Old 02-01-2013
that wont work as I mentioned earlier the file contained plenty other text and other tables so that command will return plenty of junks as well.

Is there a way to specify only "awk"-ing that specific table?
# 6  
Old 02-02-2013
You can do almost anything with awk. But unless you post your data here, it will be only guessing from us. So post real data, and what you like the output to be.
# 7  
Old 02-02-2013
The only other information I can extract from your vague (if not worse) specification is the table has 15 columns. If that is enough to tell junk from valuable input, extend ctsgnb's proposal:
Code:
awk 'NF == 15 && $6>2 {print $2}' yourfile

If that does not solve your problem, be far more specific!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating html table from data in file

Hi. I need to create html table from file which contains data. No awk please :) In example, ->cat file num1 num2 num3 23 3 5 2 3 4 (between numbers and words single TAB). after running mycode i need to get (heading is the first line): <table>... (2 Replies)
Discussion started by: Manu1234567
2 Replies

2. Shell Programming and Scripting

How to grab a block of data in a file with repeating pattern?

I need to send email to receipient in each block of data in a file which has the sender address under TO and just send that block of data where it ends as COMPANY. I tried to work this out by getting line numbers of the string HELLO but unable to grab the next block of data to send the next... (5 Replies)
Discussion started by: loggedout
5 Replies

3. Shell Programming and Scripting

Grab 2 pieces of data within a file

I am a newbie and what I have is a captured file of content. I want to be able to grab 2 pieces of data, multiple times and print them to the screen. DataFile owner: locke user: fun data size: 60 location: Anaheim owner: david user: work data size: 80 location: Orange my script... (2 Replies)
Discussion started by: greglocke
2 Replies

4. Shell Programming and Scripting

Grab data between 2 keywords any do an array operation and write the file intact

Hi Unix Gurus, I need to grep for a block that is between a start and end keyword and then in between I need to find and replace a keyword. for eg: I need to search between Test = 000; and Test = 000; and find K9 and replace with M9 INPUT FILE Define { Replace = K9; Test =... (6 Replies)
Discussion started by: naveen@
6 Replies

5. Shell Programming and Scripting

Grab the data

Hello Honourable Members, I stuck into one issue, my server is migrating from UNIX to linux and ptree command does not work there. I was working with pstree command in linux and need some help regarding the same. suppose i have one line for example: ram (121)--- sita... (3 Replies)
Discussion started by: singhabm
3 Replies

6. Shell Programming and Scripting

How to export table data to xml file?

Hi , I would like to get some suggestion from the experts. My requirement is to export oracle table data as an xml file. Any unix/linux tools, scripts available? Regards, (2 Replies)
Discussion started by: LinuxLearner
2 Replies

7. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

8. Shell Programming and Scripting

Load data to flat file from table.

Hi all, I need to know how to copy data from a table say ABC to a flat file say XYZ.dat in unix, Please leave ur comments and the fastest way to do so, I need to load the table records into flat file. Regards Ann (4 Replies)
Discussion started by: Haque123
4 Replies

9. Shell Programming and Scripting

How to grab data between 2 strings ?

Hi All, I have a text file below. How do i grab all the data between "05T00NPQSMR1" and "****" using awk ? Pls note that the text lines may not be fixed and text content is dynamic. Pls help. Thanks Below is my code where $LOT_SUFFIX is my shell variable. awk '/'"$LOT_SUFFIX"'/,/blah/'... (16 Replies)
Discussion started by: Raynon
16 Replies

10. UNIX for Dummies Questions & Answers

search and grab data from a huge file

folks, In my working directory, there a multiple large files which only contain one line in the file. The line is too long to use "grep", so any help? For example, if I want to find if these files contain a string like "93849", what command I should use? Also, there is oder_id number... (1 Reply)
Discussion started by: ting123
1 Replies
Login or Register to Ask a Question