View the Most Wanted LQ Wiki articles.
LinuxQuestions.org > Linux Wiki > Tr

From LQWiki

Jump to: navigation, search

tr is a command for translating or deleting characters. It takes a stream of input on stdin and outputs the translated stream on stdout.

Tips

tr can be used to remove characters from a stream using the -d option. Here's a quick way to convert a file with DOS end of lines (CR\LF) to UNIX end of lines:

tr -d '\015' < $FILE.dos > $FILE.unix

Another handy trick is using tr to squeeze multiple characters into one, which is sometimes handy if you want to use cut to chop things up:

ls -l | tr -s ' '

(this turns multiple spaces into one. see the cut page for a reason why this is useful)

External links


Share

Personal tools