LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   UPPERCASE to lowercase command? (https://www.linuxquestions.org/questions/linux-general-1/uppercase-to-lowercase-command-96371/)

pk21 09-24-2003 01:20 PM

UPPERCASE to lowercase command?
 
Is there a bash command to convert a word that contains a couple of uppercase letters to an all lowercase letters word?

Like converting "TeSt" to "test"

Maybe 'sed' or 'tr' ???

kev82 09-24-2003 01:28 PM

yep tr will do it fine, there are at least three examples of case converting in the info documentation for tr.

you could do it in sed but not easily.

druuna 09-24-2003 01:31 PM

Did you do man tr at all?????

$ echo "TesT" | tr [:upper:] [:lower:]
test

Or using sed

$echo "TesT" | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'
TEST

david_ross 09-24-2003 01:34 PM

You can use awk. Just pipe your string into:
awk {'print tolower($_)'}

eg:
echo TeSt | awk {'print tolower($_)'}

pujansrt 06-12-2007 10:26 AM

linux@linux:~> echo TeSt |sed 's/\(.*\)/\L\1/'
test


All times are GMT -5. The time now is 11:33 AM.