I need to do something like that using sed?
qq ab xyz ab qq aa ab
Becomes:
qq ab xyz +ab+ +qq+ aa +ab+
bashregular expressionsedtext processingword processing
I need to do something like that using sed?
qq ab xyz ab qq aa ab
Becomes:
qq ab xyz +ab+ +qq+ aa +ab+
Best Answer
If your input doesn't contain
<
,>
nor+
characters, you could do:If it may, you can always escape them:
Those assume you want to do that independently on each line. If you want to do it on the whole file, you'd need to load the whole file in memory first (note that some
sed
implementations have size limitations there):That's going to be pretty inefficient though and would be a lot easier with
perl
:Line-based: