Hello everyone I tell you that I'm trying to do a bash program that can put parentheses around each capital letter of each line using SED.
I tell you probe with:
sed -e '1,$s/A/(A)/g' "$file"
but only add parentheses in A.
then tested with:
sed 'y/AB/(A)(B)/' "$archivo"
but it gave me an error
when I'm wrong?
if someone could help me appreciate it a lot!
Thank you so much!
sed -e 's/\([[:upper:]]\)/\(\1\)/g' file
[:upper:] is a POSIX character class which matches uppercase characters in any locale. It has to be used with an RE bracket expression, i.e [...] for it to work as used above.
sed 's/[[:upper:]]/(&)/g' infile
If your sed implementation doesn't support POSIX character classes,
you could use something like this:
sed 's/[A-Z]/(&)/g' infile
Some sed implementations support the -i option to edit the input file in-place,
with others you should use a temporary file.