extracting table with awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting extracting table with awk
# 1  
Old 11-14-2008
extracting table with awk

Hi,
I am new to awk and want to create a script that finds a string of text then prints the following table to a seperate file.
I thought of using the / / identifier, but how do I retrieve the next 15 lines?
gavin
# 2  
Old 11-14-2008
Give an example of your input and desired output, ty.
# 3  
Old 11-14-2008
the input is a log file 1000's lines long containing molecular info, energies, co ordinates etc.
The output is below and its position in the file changes.

RMSD TABLE
__________

_____________________________________________________________________
| | | | | |
Rank | Sub- | Run | Binding | Cluster | Reference | Grep
| Rank | | Energy | RMSD | RMSD | Pattern
_____|______|______|___________|_________|_________________|___________
1 1 4 -5.63 0.00 24.16 RANKING
1 2 1 -5.36 4.61 28.20 RANKING
1 3 3 -5.35 4.62 28.31 RANKING
1 4 8 -5.17 4.61 28.29 RANKING
1 5 10 -5.07 4.78 29.33 RANKING
1 6 7 -5.03 4.91 29.65 RANKING
1 7 9 -4.84 2.53 23.76 RANKING
1 8 5 -4.78 4.36 28.71 RANKING
1 9 6 -4.63 2.73 26.53 RANKING
1 10 2 -4.28 2.20 25.89 RANKING
_______________________________________________________________________



Gavin
# 4  
Old 11-14-2008
What should be the desired output?

Regards
# 5  
Old 11-14-2008
this table needs extracting

RMSD TABLE
__________

_____________________________________________________________________
| | | | | |
Rank | Sub- | Run | Binding | Cluster | Reference | Grep
| Rank | | Energy | RMSD | RMSD | Pattern
_____|______|______|___________|_________|_________________|___________
1 1 4 -5.63 0.00 24.16 RANKING
1 2 1 -5.36 4.61 28.20 RANKING
1 3 3 -5.35 4.62 28.31 RANKING
1 4 8 -5.17 4.61 28.29 RANKING
1 5 10 -5.07 4.78 29.33 RANKING
1 6 7 -5.03 4.91 29.65 RANKING
1 7 9 -4.84 2.53 23.76 RANKING
1 8 5 -4.78 4.36 28.71 RANKING
1 9 6 -4.63 2.73 26.53 RANKING
1 10 2 -4.28 2.20 25.89 RANKING
_______________________________________________________________________

thanks
# 6  
Old 11-14-2008
Example:
Code:
awk '/yourpatterngoeshere/ {a=NR; print; while (NR <= a+15){getline; print}}' infile

# 7  
Old 11-14-2008
truly amazing
thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Transpose table with awk

I am trying to format the table below to the output input: cand week sub1 sub2 sub3 sub4 joe 1 94.19 70.99 43.93 60.14 joe 2 94.07 51.02 41.07 38.92 joe 3 26.24 30.95 44.56 67.67 joe 4 72.36 60.92 40.78 83.25 joe 5 51 70.01 44.66 82.22... (7 Replies)
Discussion started by: aydj
7 Replies

2. UNIX and Linux Applications

UNIX spool command not extracting complete record from the Oracle table

Hello All, I'm trying to spool an oracle table data into a csv file on unix server but the complete record is not being extracted. The record is almost 1000 characters but only 100 characters are being extracted and rest of the data getting truncated. I'm setting below options : SET... (4 Replies)
Discussion started by: venkat_reddy
4 Replies

3. Shell Programming and Scripting

Searching value in table through awk

I need to create one script in which I want to search in txt file , this txt file is having 10 columns , I want to check 4th column value if "BOY" & 10th column value =>500 it will print 4th column row value ,1st column row value & 10th column row value & store the same value in one file as... (2 Replies)
Discussion started by: dravi_laxmi
2 Replies

4. Shell Programming and Scripting

URGENT HELP!!! Extracting db table into flat file

Hi All, I am writing a shell script to extract oracle table into a pipe dilemited flat file. Below is my code and I have attached two files that I have abled to generate so far. 1. Table.txt ==> database extract file 2. flat.txt ==> pipe delimited after some manipulation of the original db... (0 Replies)
Discussion started by: express14
0 Replies

5. Shell Programming and Scripting

awk to convert table-by-row to matrix table

Hello, I need some help to reformat this table-by-row to matrix? infile: site1 A:o,p,q,r,s,t site1 C:y,u site1 T:v,w site1 -:x,z site2 A:p,r,t,v,w,z site2 C:u,y site2 G:q,s site2 -:o,x site3 A:o,q,s,t,u,z site3 C:y site3 T:v,w,x site3 -:p,routfile: SITE o p q r s t v u w x y... (7 Replies)
Discussion started by: yifangt
7 Replies

6. Shell Programming and Scripting

Table look up using awk or any other means

Hi all, I wanted to do a lookup table method using awk or any other commands. I would really appreciate any help on this. my sample input and desired outputs are given below. file1.txt is my lookuptable file, file2.txt, is the main file. file1.txt NaN NaN 33.5 0.00000000000000... (3 Replies)
Discussion started by: ida1215
3 Replies

7. UNIX for Dummies Questions & Answers

Advice on extracting special characters from a DB2 table to a file in the UNIX ENV

need some advice on the following situation. I have a DB2 table which has a varchar Column. This varchar column can have special characters like ©, ®, ™ . When I extract from this table to a sequential file for this varchar column I am only able to get © and ® . To Get the ™... (1 Reply)
Discussion started by: cosec
1 Replies

8. UNIX for Dummies Questions & Answers

Extracting all table names from a given server

Using ksh and sqlplus... does anybody have an idea of how we can possibly extract all table names from server :confused:? thanks in advance. (6 Replies)
Discussion started by: fmina
6 Replies

9. UNIX for Dummies Questions & Answers

Extracting column names from a table.. SQL with UNIX

:rolleyes: hi there everybody, i need help,... thanks anyway! i am working on a very huge table with the name table1. the problem is that i know only one field name in this table..., working with a ksh environment i don't know how to view the table to check out the field names :confused:. ... (4 Replies)
Discussion started by: fmina
4 Replies

10. Shell Programming and Scripting

Extracting Table names from a Select Stament

Hi, I am working on a code to extract the table names out of a select statement. Is there anybody who has worked on something similar? May be you could provide me with the regular expression for the same. Regards. Silas (2 Replies)
Discussion started by: silas.john
2 Replies
Login or Register to Ask a Question