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!

Repacing a string in only 1 column

Status
Not open for further replies.

lbzh

Programmer
Aug 7, 2004
25
US
I have a file and I wish to replace a specific column if it contains a value to another value

An example is below:

Input file

222222
121111
323333

I wish to replace the "2" in the 2nd column to a "9" , all other columns remain intact, so the output looks like this:

299999
191111
393333

Thanks
 
sed -e 's/^\(.\).\(.*\)/\19\2/g' myFile

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
A starting point:
sed 's!^\(.\)2!\19!' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top