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

awk command to change strings

Status
Not open for further replies.

Yarka

Technical User
Jan 14, 2007
192
ES
Hi everybody,

I would like to know how I can use awk command for when it reads a specific string then change the following other strings of the same row.

For example:
If I have a file like:

aa 22 33
bb 33 23
bt 34 98
a4 99 100
aa 44 66
f6 90 09
...

I need to change all the strings 'aa' the following columns need to have the values 88 80, so the result would be:

aa 88 80
bb 33 23
bt 34 98
a4 99 100
aa 88 80
f6 90 09
...

Could be somebody help me?

Thank you.

 

Code:
awk '$1 ~ /aa/{print $1,88,80}'
(not tested)


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
awk '$1=="aa"{print $1,88,80;next}1'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top