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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrive information? 1

Status
Not open for further replies.

percent

IS-IT--Management
Apr 27, 2004
176
0
0
US
I'm having trouble finding finding a command that does what I need. What I need to do is retrive information from a table like list(an example is below - I need to retrive variables from for two different type of lists - these are for two seperate script they are just related in what I need done):

(List #1)
VarA1 VarA2 VarA3
VarB1 VarB2 VarB3
VarC1 VarC2 VarC3
VarD1 VarD2 VarD3

(List #2)
VarA1:VarA2:VarA3
VarB1:VarB2:VarB3
VarC1:VarC2:VarC3
VarD1:VarD2:VarD3

What I want to beable to do is retrive a variable from the list - I would like to beable to specify what row and what column to retrive the value for. Any help is appreciated.


%, 2004
 
Code:
# extract row 2 column 2 from your first file
awk -v r=2 -v c=2 'NR==r { print $c }' file.txt

Use the -F option of awk to change the separator when dealing with the second file.


--
 
Thank You - Worked Perfect(Exactly what I was looking for)

%, 2004
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top