How to extract data from a text file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to extract data from a text file
# 1  
Old 07-19-2005
How to extract data from a text file

Hello All,

Is there an easy way to extract data from a text file? The text file is actually a dump of a 2 page report with 6 columns and 122 lines. Example is

Report Tile

Type Product 1 Product 2 Product 3 Product 4 Product 5

Budget

Current
MTD
YTD.

Payments

Second Page of Report :
Report Tile

Type Product 6 Product 7 Product 8 Product 9 Grand Total

Budget

Current
MTD
YTD.

Payments



Say we only want to get the amount in :
Current - Product8, Product 9 and grand total.
MTD - Product8, product9 and Grand total
YTD - product8, product9 and Grand Total

Checking the text file, these are in rows 81, 82 and 83.

Thanks!


negixx
# 2  
Old 07-19-2005
Maybe try something like...
Code:
awk 'NR>=81 && NR<=83 {print $4, $5, $6}' file1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell - Read a text file with two words and extract data

hi I made this simple script to extract data and pretty much is a list and would like to extract data of two words separated by commas and I would like to make a new text file that would list these extracted data into a list and each in a new line. Example that worked for me with text file... (5 Replies)
Discussion started by: dandaryll
5 Replies

2. Shell Programming and Scripting

Extract data from a file

I have a text file that contains the following data. For example, aa.txt has some numbers. I need to extract the continuous numbers(minimum 3 numbers) from it.How can I do this with awk? >aa.txt 31 35 36 37 38 39 44 169 170 173 174 175 177 206 >1a.txt 39 (5 Replies)
Discussion started by: rahmanabdulla
5 Replies

3. Shell Programming and Scripting

awk used to extract data between text

Hello all, I have a file (filename.txt) with some data (in two columns X and Y) which looks like this: ########## 'Header1' 'Sub-header1' X Y xxxx.xx yyyy.yyy xxxx.xx yyyy.yyy .... ... 'Sub-header2' X Y xxxx.xx ... (7 Replies)
Discussion started by: jaldo0805
7 Replies

4. Shell Programming and Scripting

Extract header data from one file and combine it with data from another file

Hi, Great minds, I have some files, in fact header files, of CTD profiler, I tried a lot C programming, could not get output as I was expected, because my programming skills are very poor, finally, joined unix forum with the hope that, I may get what I want, from you people, Here I have attached... (17 Replies)
Discussion started by: nex_asp
17 Replies

5. Shell Programming and Scripting

regular expression with shell script to extract data out of a text file

hi i am trying to extract some specific data out of a text file using regular expressions with shell script that is using a multiline grep .. and the tool i am using is pcregrep so that i can get compatibility with perl's regular expressions for a sample data like this, i am trying to grab... (6 Replies)
Discussion started by: vemkiran
6 Replies

6. Shell Programming and Scripting

SED to extract HTML text data, not quite right!

I am attempting to extract weather data from the following website, but for the Victoria area only: Text Forecasts - Environment Canada I use this: sed -n "/Greater Victoria./,/Fraser Valley./p" But that phrasing does not sometimes get it all and think perhaps the website has more... (2 Replies)
Discussion started by: lagagnon
2 Replies

7. Shell Programming and Scripting

Extract multiple repeated data from a text file

Hi, I need to extract data from a text file in which data has a pattern. I need to extract all repeated pattern and then save it to different files. example: input is: ST*867*000352214 BPT*00*1000352214*090311 SE*1*1 ST*867*000352215 BPT*00*1000352214*090311 SE*1*2 ... (5 Replies)
Discussion started by: apjneeraj
5 Replies

8. Programming

c program to extract text between two delimiters from some text file

needa c program to extract text between two delimiters from some text file. and then storing them in to diffrent variables ? text file like 0: abc.txt ========= aaaaaa|11111111|sssssssssss|333333|ddddddddd|34343454564|asass aaaaaa|11111111|sssssssssss|333333|ddddddddd|34343454564|asass... (7 Replies)
Discussion started by: kukretiabhi13
7 Replies

9. Shell Programming and Scripting

extract data from file

I m new to shell scripting & i need a help.... i have file like.... Name := sachin address:=something phone:=111 ... Note: There might be or not space between Name & := and between := & sachin. I need to extract the data from each line of file as var1=Name value1=sachin same for... (13 Replies)
Discussion started by: ps_sach
13 Replies

10. Shell Programming and Scripting

extract data from file

Hello again, how do you extract data from a file? I have created a file with PID #s in it, I need to be able to take the PID from each line and kill it. How is this done? (4 Replies)
Discussion started by: raidzero
4 Replies
Login or Register to Ask a Question