Linux命令里面两个很经典的命令:join和tr(原创 )

Linux命令里面两个很经典的命令:join和tr
作者 余超 email:[email protected]


下面先看一下join命令的使用方法:
对于合并两个具有相同文件头的方法合并起来是一种很好的方法:
[yuchao@yuchao-Latitude-E5410 source]$cat sinadept.txt 
100 Harry Potter:100:Magic School
200 Alex Jason:200:Sales
300 Yu Chao:300:SINA Product Development
400 Sanjay Gupta:400:Support
500 Nisha Singh:500:Sales
1000 Yu Jun:1000:Peking University EECS
[yuchao@yuchao-Latitude-E5410 source]$cat sinasalary.txt 
100 $1000
200 $1234
300 $892 
400 $2389
500 $123
1000 $2389
[yuchao@yuchao-Latitude-E5410 source]$join sinadept.txt sinasalary.txt 
100 Harry Potter:100:Magic School $1000
200 Alex Jason:200:Sales $1234
300 Yu Chao:300:SINA Product Development $892 
400 Sanjay Gupta:400:Support $2389
500 Nisha Singh:500:Sales $123
1000 Yu Jun:1000:Peking University EECS $2389
[yuchao@yuchao-Latitude-E5410 source]$join sinasalary.txt sinadept.txt 
100 $1000 Harry Potter:100:Magic School
200 $1234 Alex Jason:200:Sales
300 $892  Yu Chao:300:SINA Product Development
400 $2389 Sanjay Gupta:400:Support
500 $123 Nisha Singh:500:Sales
1000 $2389 Yu Jun:1000:Peking University EECS


在看一下tr命令,对于需要执行整篇文章进行大小写转换的处理时很有用:
如下:
[yuchao@yuchao-Latitude-E5410 source]$tr a-z A-Z <sinadept.txt 
100 HARRY POTTER:100:MAGIC SCHOOL
200 ALEX JASON:200:SALES
300 YU CHAO:300:SINA PRODUCT DEVELOPMENT
400 SANJAY GUPTA:400:SUPPORT
500 NISHA SINGH:500:SALES
1000 YU JUN:1000:PEKING UNIVERSITY EECS
[yuchao@yuchao-Latitude-E5410 source]$tr A-Z a-z <sinadept.txt 
100 harry potter:100:magic school
200 alex jason:200:sales
300 yu chao:300:sina product development
400 sanjay gupta:400:support
500 nisha singh:500:sales
1000 yu jun:1000:peking university eecs
[yuchao@yuchao-Latitude-E5410 source]$
如果文件过大的话处理起来很方便,如果你会VIM或者是其他工具的话,
也有很好的方法用来处理同样的问题。

你可能感兴趣的:(JOIN,linux,vim,email,工具)