I have temp
file with some lower-case and upper-case contents.
Input
Contents of my temp
file:
hi
Jigar
GANDHI
jiga
I want to convert all upper to lower.
Command
I tried the following command:
sed -e "s/[A-Z]/[a-z]/g" temp
but got wrong output.
Output
I want it as:
hi
jigar
gandhi
jiga
What needs to be in the substitute part of argument for sed
?
Best Answer
If your input only contains ASCII characters, you could use
tr
like:or (less easy to remember and type IMO; but not limited to ASCII latin letters, though in some implementations including GNU
tr
, still limited to single-byte characters, so in UTF-8 locales, still limited to ASCII letters):if you have to use
sed
:(here assuming the GNU implementation).
With POSIX
sed
, you'd need to specify all the transliterations and then you can choose which letters you want to convert:With
awk
: