GNU/Linux Command – TR

tr – TRanslate or Delete characters

Summary :
tr will translate, squeeze, and/or delete characters from stdin and writing to stdout.

Examples :
$ echo "tenet" | tr "nt" "NT" -- Translate n to N and t to T. $ echo "ilugc" | tr "[a-z]" "[A-Z]" -- Change case (lowerto upper). $ echo "HelloooOOOoooo" | tr -s '[:lower:]' -- Squeez the"lower" case letters. $ echo "IxLyUzGyC" | tr -d xyz -- Remove xyz characters. $ cat myfile | tr -s 'n' -- Remove repeated new lines. $ echo "ABCDEFG" | tr -c "ACEG" "n" -- Expect "ACEG" translateothers to newline char.
‘tr’ supports few standard ESC Sequences, Regular Expressions, Char Classes (lower, upper, space, blank, alpha,..), etc.

Read : man tr

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: