Tr: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{lowercase title}} | {{lowercase title}} | ||
translate or delete characters | |||
http://linux.die.net/man/1/tr | http://linux.die.net/man/1/tr |
Latest revision as of 18:08, 20 April 2011
translate or delete characters
http://www.cyberciti.biz/faq/how-to-use-linux-unix-tr-command/
Count the number of slashes in a string:
echo "/incoming/data/" | tr -dc '/' | wc -c # gives 3
Convert to uppercase:
echo 'linux' | tr "[:lower:]" "[:upper:]" # LINUX echo 'linux' | tr "a-z" "A-Z" # LINUX
Remove all non-printable characters from myfile.txt
tr -cd "[:print:]" < myfile.txt