ODOC: tr

Thursday, December 08, 2005

tr - Translate or Delete characters

Summary :

tr will Translate, squeeze, and/or delete characters from stdin, writing to stdout.

Examples :
$ echo "fslog" | tr "fs" "FS" -- Translate f to F & s to S.

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

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

$ echo "FxSyLzoyg" | 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.
'tr' supports few std esc sequences, regular expressions, char classes
(lower, upper, space, blank, alpha,...), etc.

Read : man tr
Tech Tags:

comments links to this post Listen to this article Listen to this article


Post a Comment

Links to this post:

Create a Link

<< Home

Previous Posts

referer referrer referers referrers http_referer

  • Subscribe to Free Software Blog
  • Google
  • Subscribe in Yahoo
  • Subscribe
in Bloglines
  • Link to Podcast

(RSS feed) for this blog
    Computers Blog Top Sites
  • Computers Blogs by Indian Bloggers
  • BLogstreet Profile