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

Awk help

Status
Not open for further replies.

chipmate

Technical User
Dec 9, 2010
1
0
0
IN
Hi

After run I do get 5 or 6 file every day ,I have a fixed file1 also ,What I want that awk will read file one and get matched line from other file and write result in next column --
like -RESULT
-----------------file1--file2----file 3---file4--------------------------
app man TRUE FALSE TRUE TRUE
mo mi FALSE FALSE FALSE FALSE
ch chu TRUE TRUE TRUE TRUE
tik tok TRUE TRUE TRUE TRUE

file 1--

app man
mo mi
ch chu
tik tok

file 2 --Diffrent order
app man TRUE
tik tok TRUE
mo mi FALSE
ch chu TRUE

file 3- diffrent order
app man FALSE
tik tok FALSE
mo mi TRUE
ch chu TRUE

file 4- diffrent order
app man TRUE
tik tok FALSE
mo mi TRUE
ch chu TRUE


Thanks in advance
Chipmate
 
Quick & dirty (and doesn't give the ouput in the order that the records appear in file1):

Code:
for file in file1 file2 file3 file4
do
  sort -o $file $file
done

paste file1 file2 file3 file4|awk '{print $1,$2,$5,$8,$11}'

But I'm sure someone will come up with an all-awk (array) solution.

HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top