Replace a column in a file using aw

March 30, 2009 at 23:29:29
Specs: Solaris
I want to search for a pattern in a file , and replace some other column in the same line with a new value . I dont want to create a new file
For eg


aaa dddd 1122f 4455h

Search for pattern 'aaa' and replace 1122f with a new value , note that thees values are not constant

Can anyone please help me

See More: Replace a column in a file using aw

Report •

March 30, 2009 at 23:44:55
The columns in the file are separates from tabs and spaces
aaa 000 00 112 4444

I want to retain the same sepation between the columns
The command may be either in awk or sed.
please help me

Report •

March 31, 2009 at 01:39:05
awk '$1=="aaa"{$3="newvalue"}1'

Report •

March 31, 2009 at 21:52:21
I am using Solaris OS , the above command does not work.
Thanks for the reply.

Report •

Related Solutions

March 31, 2009 at 22:34:34
use nawk for solaris. change the "1" at the end to "{print $0}" if you want.

Report •

March 31, 2009 at 22:51:49

Report •

Ask Question