tr (translation) modify string in a text file

    • tr

(translation). A filter useful to replace all instances of characters in a text file or “squeeze” the whitespace.

Example:


cat some_file | tr '3' '5' > new_file

This will run the cat program on some file, the output of this command will be sent to the trcommand, tr will replace all the instances of 3 with 5, like a search and replace. You can also do other things such as:


cat some_file | tr '[A-Z]' '[a-z]' > new_file

This will run cat on some_file and convert any capital letters to lowercase letters (you could use this to change the case of file names too…).

 

source: http://linux.about.com/od/lts_guide/a/gdelts43_3.htm

Anuncis

Deixa un comentari

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

WordPress.com Logo

Esteu comentant fent servir el compte WordPress.com. Log Out /  Canvia )

Google+ photo

Esteu comentant fent servir el compte Google+. Log Out /  Canvia )

Twitter picture

Esteu comentant fent servir el compte Twitter. Log Out /  Canvia )

Facebook photo

Esteu comentant fent servir el compte Facebook. Log Out /  Canvia )

w

S'està connectant a %s


%d bloggers like this: