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

Substitution query

Status
Not open for further replies.

ranjit

Technical User
Apr 14, 2000
131
GB
[tt]

# input file
100.21.56.222.22
100.22.56.222.24
100.23.56.222.370
100.24.56.222.2390
server33.22
server45.670

# desired ouput
100.21.56.222,22
100.22.56.222,24
100.23.56.222,370
100.24.56.222,2390
server33,22
server45,670

How do I go about substituting the final "." (dot) to a comma in the above input file ?

[/tt]
 
The sed way:
sed 's!\.\([^.]*\)$!,\1!' /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
 
Many thanks PHV - certainly works.

However could you please explain the logic underpinning the substitution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top