[SYNTAX] tr command

Unix C++ :: UNIX CPP :: UNIX :: SYNTAX

Go down

[SYNTAX] tr command

Post by Christopher on Sun Mar 14, 2010 12:02 pm

Translate characters.

Syntax

Code:
tr [-c] [-d] [-s] [string1] [string2]

-c Complement the set of characters specified by string1.
-d Delete all occurrences of input characters that are specified by string1.
-s Replace instances of repeated characters with a single character.
string1 First string or character to be changed.
string2 Second string or character to change the string1.

Examples
Code:

$ cat 1.txt
hi u der
make hi files wonderful
things computer windows hi
hi make ubuntu files
recover delete hi things
computer
computerjee

$ tr -c '[a-k]\n' '@' < 1.txt
hi@@@de@
@ake@hi@fi@e@@@@@de@f@@
@hi@g@@c@@@@@e@@@i@d@@@@hi
hi@@ake@@b@@@@@fi@e@
@ec@@e@@de@e@e@hi@@hi@g@
c@@@@@e@
c@@@@@e@jee

$ tr -d ' ' < 1.txt
hiuder
makehifileswonderful
thingscomputerwindowshi
himakeubuntufiles
recoverdeletehithings
computer
computerjee

$ tr -t '[a-z]' '[A-Z]' < 1.txt
HI U DER
MAKE HI FILES WONDERFUL
THINGS COMPUTER WINDOWS HI
HI MAKE UBUNTU FILES
RECOVER DELETE HI THINGS
COMPUTER
COMPUTERJEE


Source : http://www.computerhope.com/unix/utr.htm
avatar
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 30

View user profile http://unixcpp.forumotion.com

Back to top Go down

Back to top

- Similar topics

Unix C++ :: UNIX CPP :: UNIX :: SYNTAX

 
Permissions in this forum:
You cannot reply to topics in this forum