Linux命令裡面兩個很經典的命令:join和tr(原創 )

來源:互聯網
上載者:User

Linux命令裡面兩個很經典的命令:join和tr
作者 餘超 email:yuchao86@gmail.com

下面先看一下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或者是其他工具的話,
也有很好的方法用來處理同樣的問題。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.