Pergunta

So I was searching around and using the command tr you can convert from lower case to upper case and vice versa. But is there a way to do this both at once?

So:

$ tr '[:upper:]' '[:lower:]' or  $ tr A-Z a-z

Will turn "Hello World ABC" to "hello world abc", but what I want is "hELLO wORLD abc".

Foi útil?

Solução

This will do what you are looking for:

 tr '[:upper:][:lower:]' '[:lower:][:upper:]'

Outras dicas

I think tr '[a-zA-Z]' '[A-Za-z]' is more straight forward, and easier to remember.

You can use \L& and \U& to convert to lower and upper case respectively:

$echo "SUJIT dhamale " | sed 's/.*/\L&/g'

Result: sujit dhamale

$ echo "SUJIT dhamale " | sed 's/.*/\U&/g'

Result: SUJIT DHAMALE

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top