I would like to put one word in parenthesis with sed and a regex but I don't know how to do it.
I think the command shoud look a little bit like this :
sed -r "s/???/\(&\)/g"
but I don't know know how to match a word without whitespaces...
If I try on this example :
WORD
abc = WORD
I get :
(WORD)
(abc = WORD)
What I want is :
(WORD)
abc = (WORD)
CodePudding user response:
Using sed
, you can match capitalized characters
$ sed 's/[[:upper:]]\ /(&)/' input_file
(WORD)
abc = (WORD)
or the last alphabetic characters at the end of the line
$ sed 's/[[:alpha:]]\ $/(&)/' input_file
(WORD)
abc = (WORD)
CodePudding user response:
I found what I was looking for :
sed -r "s/\S /\(&\)/g""
It was quite simple actually.