Computing.Net > Forums > Unix > awk line number

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

awk line number

Reply to Message Icon

Name: jayde
Date: March 5, 2007 at 22:41:31 Pacific
OS: windows xp
CPU/Ram: p4
Product: wipro
Comment:

I need to extract data from a flat file with a package name(ABC.XYZ.W)with other packages too. Eg.


| 12345678| 993600| ABHUY | WIGB
| 98765432| 995640| DSGFKDSJGS | R003
#EOD
*
*
# 4 COUNTRIES'WEIGHT DNCA.CTY.W 20070131
# 1 Calculation Date calc_date D 8 0
# 2 MSCI Index Code msci_index_code N 6 0
# 3 ISO Country Symbol ISO_country_symbol S 3 0
# 4 Country Weight country_weight N 8 4
*
# 1 2 3 4
SSL>>>>>>>SSV>>>>>SSL>>SSV>>>>>>>
| 20123131| 106330| AU | 3.1398
| 20050131| 106330| CA | 4.1201
| 26701315| 106330| CH | 3.9537
| 20078931| 106330| DK | 0.4766
| 20056131| 106330| GB | 13.3372

The main file calls a txt file with using awk commands to extract the data through the command.

awk -f "./awk_dnca.txt" $MSCI_DATA_DIR/$FILE_2 > "./file_ABC.dat".

I am trying to get the line number where the text WEIGHT is searched and take all subsequent line numbers.

The code I am using is

lineno= grep -n WEIGHT $4
echo $lineno
BEGIN{ FS="|" } /^\|/ {if ( NF == 4 && $lineno > NR) print $2"|"$3"|"$4}




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: awk line number

grep to find a specific line number www.computing.net/answers/unix/grep-to-find-a-specific-line-number/6484.html

Searching by line number www.computing.net/answers/unix/searching-by-line-number/4285.html

VI line number www.computing.net/answers/unix/vi-line-number/7491.html