One Day One GNU/Linux Command (TR)

4 views
Skip to first unread message

Bharathi Subramanian

unread,
Jun 5, 2008, 1:27:35 AM6/5/08
to GNU/Linux Users Group - Trichy, GNU/Linux User Group of TCE, VEC-FOSS
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

Reply all
Reply to author
Forward
0 new messages