#tr -[ds] SET1 [SET2]
选项和参数:
:没有参数,使用SET2的字符取代SET1中的字符
-d :删除SET1中包含的字符
-s :取代连续重复的字符
[email protected]:~/shell# cat file
Massachusetts
Virginia
//没有参数,取代将字符M、V取代为K
[email protected]:~/shell# cat file | tr MV K
Kassachusetts
Kirginia
//-d参数,删除字符M、s
[email protected]:~/shell# cat file | tr -d Ms
aachuett
Virginia
//-d参数,删除字符i
[email protected]:~/shell# cat file | tr -d i
Massachusetts
Vrgna
//将出现的一个字符s或多个连续出现的字符s使用一个K代替
[email protected]:~/shell# cat file | tr -s s K
MaKachuKettK
Virginia
#col -x
选项和参数:
-x :将tab以相等数量的空格取代
#cat的-A选项显示特殊的按键
[email protected]:~/shell# cat -A test
Massachusetts^IVirginia^ITulsa$
Falls^IMassachusetts^IVirginia$
View^IMassachusetts^Iview$
//空格取代tab键
[email protected]:~/shell# cat test | col -x | cat -A
Massachusetts Virginia Tulsa$
Falls Massachusetts Virginia$
View Massachusetts view$
#join -[ti12] FILE1 FILE2
选项和参数:
-t :指定分隔的字符,默认是空格符分隔并且对比第一个字段
-i :忽略大小写
-1 N FILE1 -2 M FILE2 : 将FILE1的N字段和FILE2的M字段对比
[email protected]:~/shell# paste -d @ file1 file2
John Dagget, 341 King Road, [email protected] Dagget, Plymouth, Massachusetts
Alice Ford, 22 East Broadway, [email protected] Ford, Ricahmond, Virginia
[email protected]:~/shell# join -t , file1 file2
John Dagget, 341 King Road, Plymouth, Plymouth, Massachusetts
Alice Ford, 22 East Broadway, Ricahmond, Ricahmond, Virginia
[email protected]:~/shell# join -t , -1 3 file1 -2 2 file2
Plymouth,John Dagget, 341 King Road,John Dagget, Massachusetts
Ricahmond,Alice Ford, 22 East Broadway,Alice Ford, Virginia