linux - How to replace column 3 with column 1 when it has a specific word? -


i have 3 column data file of format below:

convicts np convict console  jj <unknown> apples   np apple 

so, here have word console in place word "unknown" is.

ps: huge file contains word "unknown" multiple number of times. so, wherever word "unknown" occurs in third column, want replaced it's corresponding 1st column word.

i tried using command

awk ' { $3="unknown"; $3=$1; print } ' <filename>  

but replaces entire 3rd column words of 1st column. please how can rectify this. in advance!

if want replace <unknown> corresponding lines first column value:

awk '$3=="<unknown>"{$3=$1;} {print};' filename 

Comments

Popular posts from this blog

android - questions about switching from C2DM to GCM -

c++ - Qt setGeometry: Unable to set geometry -

batch file - How to extract all multi-volume RAR archives from subfolders of a folder? -