1
sed "s/[a-z]/$1/g" <old.txt>new.txt echo "done" 

This only replaces lowercase letters with the first parameter given. I want to replace everything except uppercase letters.

1 Answer 1

5
sed "s/[^[:upper:]]/$1/g" 

Would replace all characters that are not considered as an upper-case letter in your locale with the content of $1 (provided $1 doesn't contain &, backslash or slash or newline characters).

Note that it would not replace bytes that are not part of valid characters. It will also happily convert combining characters. For instance, É is an upper-case character. If written as the U+00C9 character, it will be left alone, but if written as E followed by the combining acute accent character (U+0301), that will be changed to E$1.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.