some name;another thing; random; value value value value value
I'm trying to replace the spaces that occur after the random;
using sed. It's important to keep the spaces that is in some name
for example.
This replaces all spaces with comma. How could I match a expression like *;*;*;
and use sed with the rest of the line and replace spaces with comma?
sed -e 's/ /,/g'
Thanks
Best Answer
Using
gsub()
inawk
on the last;
-delimited field:Using
sed
and assuming we'd like to replace all spaces after the last;
with commas:Annotated
sed
script:The "hold space" is a separate storage buffer that
sed
provides. The "pattern space" is the buffer into which the data is read from the input and to which modifications may be applied.