Extracting content from a file in specific format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extracting content from a file in specific format
# 1  
Old 07-12-2012
Extracting content from a file in specific format

Hi All,

I have the file in this format

Code:
**** Results Data ****

Time or Step
1
2
20


0.000000000e+00     0s    0s    0s
1.024000000e+00     Us    0s    0s
1.100000000e+00     1s    0s    0s
1.100000001e+00     1s    0s    1s
2.024000000e+00     Us    Us    1s
2.024000001e+00     Us    Us    0s
2.100000000e+00     0s    1s    0s
2.100000001e+00     0s    1s    1s
3.024000000e+00     Us    1s    1s
3.024000001e+00     Us    1s    0s
3.100000000e+00     1s    1s    0s

**** Statistics ****

Operating point analog/event alternations:  1
Operating point load calls:                 4
Operating point event passes:               2
Transient analysis load calls:              84
Transient analysis timestep backups:        0

I have to extract only the the content in bold format.

Thanks in Advance

Last edited by Scrutinizer; 07-12-2012 at 04:38 AM.. Reason: code tags
# 2  
Old 07-12-2012
Code:
 
awk '$0~/^[0-9].*s$/' input.txt

This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 07-12-2012
Hi

Code:
 awk '/^[0-9].*s$/' file

This User Gave Thanks to guruprasadpr For This Post:
# 4  
Old 07-12-2012
Thanks a lot for your help.
One more help is required

Code:
0.000000000e+00 0s 0s 0s
1.024000000e+00 Us 0s 0s
1.100000000e+00 1s 0s 0s
1.100000001e+00 1s 0s 1s
2.024000000e+00 Us Us 1s
2.024000001e+00 Us Us 0s
2.100000000e+00 0s 1s 0s
2.100000001e+00 0s 1s 1s
3.024000000e+00 Us 1s 1s
3.024000001e+00 Us 1s 0s
3.100000000e+00 1s 1s 0s

I want just the final stable result for time 0,1,2 and 3 in bold line.
In between this (no matter how many times it repeat) is not required.

Thanks!!!!!!!!!

Last edited by Scrutinizer; 07-12-2012 at 04:37 AM.. Reason: code tags
# 5  
Old 07-12-2012
Try:
Code:
awk -F. '/^[0-9].*s/{if($1!=n)print p; p=$0; n=$1}END{print p}' infile

--
Please view this link to learn the use of code tags.
# 6  
Old 07-12-2012
Can we include the term of 0 line in bold ?
# 7  
Old 07-12-2012
I made a small correction in my post right after I posted. Perhaps you tried the first (wrong) version? Could you test with the version that you see right now?
This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Linux read specific content file from tar.gz files without extracting

hello i wish to write the result of these below conditions in a file: 1. in a specific folder, i have many tar.gz files. 2. each tar.gz file contains ".dat" file in sub folders. 3. i wish to get the full path of these .dat files, if i find in it a specific word ("ERROR24"). 4. all this... (6 Replies)
Discussion started by: jimmyjames9
6 Replies

2. Shell Programming and Scripting

Extracting content from xml file

Hello All, Hope you are doing well!!!!! I have a small code in the below format in xml file: <UML:ModelElement.taggedValue> <UML:TaggedValue tag="documentation" value="This sequence&#xA;&#xA;HLD_EA_0001X&#xA;HLD_DOORS_002X"/> <UML:TaggedValue tag="documentation" value="This... (11 Replies)
Discussion started by: suvendu4urs
11 Replies

3. UNIX for Dummies Questions & Answers

Extracting specific files from a tar file in HP-UX

I have tried: tar -xfv mytarfile.tar archive/tabv/* tar -xfv mytarfile.tar --wildcards 'archive/tabv/*' tar -xf mytarfile.tar -v --wildcards 'archive/tabv/*' tar -xfv mytarfile.tar --wildcards --no-anchored 'archive/tabv/*' tar -xfv mytarfile.tar --wildcards `archive/tabv/*` and none... (5 Replies)
Discussion started by: zapper222
5 Replies

4. Shell Programming and Scripting

Extracting content of a file

Hello, I'm working on a script to extract the contents of a file (in general, plain txt file with numbers, symbols, and letters) and output it into a .txt file. but it is kind of all over the place. It needs to not include duplicates and the content has to be readable. I jumped all over the place... (7 Replies)
Discussion started by: l20N1N
7 Replies

5. Shell Programming and Scripting

Using Awk for extracting data in specific format

please help me writing a awk script 001_r.pdb 0.0265185 001_r.pdb 0.0437049 001_r.pdb 0.0240642 001_r.pdb 0.0310264 001_r.pdb 0.0200482 001_r.pdb 0.0146746 001_r.pdb 0.0351344 001_r.pdb 0.0347856 001_r.pdb 0.036119 001_r.pdb 1.49 002_r.pdb 0.0281011 002_r.pdb 0.0319908 002_r.pdb... (5 Replies)
Discussion started by: phoenix_nebula
5 Replies

6. Shell Programming and Scripting

Assigning a specific format to a specific column in a text file using awk and printf

Hi, I have the following text file: 8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm 9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm 10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm 11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies

7. UNIX for Dummies Questions & Answers

Content format in a text file

Hi, I need to format the content in a text file as below format. Can some one help me how to approach? Also whether is it possible to convert the output to excel in column wise? Present: ============================================================================= Name: vinodh Status:... (1 Reply)
Discussion started by: vino_hymi
1 Replies

8. Shell Programming and Scripting

extracting specific lines from a file

hi all, i searched in unix.com and accquired the following commands for extracting specific lines from a file .. sed -n '16482,16482p' in.sql > out.sql awk 'NR>=10&&NR<=20' in.sql > out.sql.... these commands are working fine if i give the line numbers as such .. but if i pass a... (2 Replies)
Discussion started by: sais
2 Replies

9. Shell Programming and Scripting

How to read the content of the particular file from tar.Z without extracting?

Hi All, I want to read the content of the particular file from tar.Z without extracting. aaa.tar.Z contains a file called one.txt, I want to read the content of the one.txt without extracting. Please help me to read the content of it. Regards, Kalai. (12 Replies)
Discussion started by: kalpeer
12 Replies

10. Shell Programming and Scripting

Extracting specific text from a file

Dear All, I have to extract a a few lines from a log file and I know the starting String and end string(WHich is same ). Is there any simplere way using sed - awk. e.g. from the following file -------------------------------------- Some text Date: 21 Oct 2008 Text to be extracted... (8 Replies)
Discussion started by: rahulkav
8 Replies
Login or Register to Ask a Question