[Ilugc] One Day One GNU/Linux Command (TR)

  • From: sbharathi@xxxxxxxxxxxxx (Bharathi Subramanian)
  • Date: Thu Jun 5 10:49:27 2008

One Day One GNU/Linux Command
=============================

tr - TRanslate or Delete characters

Summary: 

tr will translate, squeeze, and/or delete characters from stdin,
writing to stdout. 'tr' supports few standard Esc sequences, regular
expressions, char classes (lower, upper, space, blank, alpha ...),
etc.

Examples:

$ echo "tenet" | tr "tn" "TN" -- Translate t to T & n to N.

$ echo "ilugc" | tr "[a-z]" "[A-Z]" -- Change case (lower to upper)

$ echo "ilugc" | tr '[:lower:]' '[:upper:]' -- Same as above.

$ echo "HelloooOOOoooo" | tr -s '[:lower:]' -- Squeeze the "lower" 
                                               case letters.

$ echo "IwLxUyGzC" | tr -d xyz -- Remove xyz

$ cat myfile | tr -s '\n' -- Remove repeated new lines.

$ echo "ABCDEFG" | tr -c "ACEG" "\n" -- Expect "ACEG" translate 
                                        others to newline char.

Read : man tr

Bye :)
-- 
Bharathi S

Other related posts:

  • » [Ilugc] One Day One GNU/Linux Command (TR) - Bharathi Subramanian