Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to read a specific line out of a file 1

Status
Not open for further replies.

Birbone

MIS
Dec 20, 2000
141
US
I am trying to learn something new. I know I can cat a file, read each record, and utilize a counter until I get to a specific line number. Is there a way to pull just a specific line out of a file?

I trying to find something as clean as how
awk '{print $2}'
pulls just the second column.

I am working with a testfile that is set up in a grid, and I want to efficiantly pull the value from a specific slot based on xy cordinates fed from a seperate file. The actual file will be quite large.

testfile would look like this
f0 f1 f2 f3 f4
f5 f6 f7 f8 f9
fa fb fc fd fe

so if the value from the other file is 32, then by echoing the $data in row 3 column 2, we get an output of "fb"

I am looking for the fastest and cleanest way. My thought was to grab just the specific line and then awk the column.
Looking forward to reading your ideas. Thanks.


-Bobby s-)
bwgunn@icqmail.com
 
Hi,
Please see

thread80-224772

in the general UNIX Discusion forum for getting the specific line out of a file.

then once you have the specific line pipe it into CUT.

echo $line | cut -d' ' -f $col

where $col is the column of the line you want.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top