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

change the last occurence in each line 1

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL
eg. replace last occurrence of "50" to "XX" in each line:

[COLOR=dark violet] input:[/color]
one.two.50.three.50.
ble.5040.50.one
111.5011.three
5023.550.ccc50.5000.sdd50...


[COLOR=dark violet] output:[/color]
one.two.50.three.XX.
ble.5040.XX.one
111.XX11.three
5023.550.ccc50.5000.sddXX...


thank you in advance!
 
rev </path/to/file|sed 's/05/XX/'|rev

is one way...


HTH,

p5wizard
 
Why not simply this ?
sed 's!\(.*\)50!\1XX!' input > output

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,

I am not as fluent in sed as you are, so I improvise...



HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top