View Single Post
Old 3rd January 2009
s0xxx's Avatar
s0xxx s0xxx is offline
Package Pilot
 
Join Date: May 2008
Posts: 192
Default

Sorry to kick-in late, great guide j65nko! But was there a need for using regexp? Could have a simple sed 's/-/_/' file do the job? I see the pattern is repeating and you needed to change only the first occurrence of "-" in string (note there is no g at the end).

Also noone offered an awk solution to the problem:
Code:
awk '{ sub(/-/,"_"); print }' file
(also not using gsub for global change)
__________________
The best way to learn UNIX is to play with it, and the harder you play, the more you learn.
If you play hard enough, you'll break something for sure, and having to fix a badly broken system is arguably the fastest way of all to learn. -Michael Lucas, AbsoluteBSD
Reply With Quote