1 / 8

grep 尋求特定字串

grep 尋求特定字串. 由標準輸入依照樣本字元逐行搜尋 只要包含所要的樣本字元都會印在標準輸出上 grep [-cilnv] pattern [filelist] 找出以 l 開始的行列 ls -l /bin | grep ^l 找出 process 中含有 melanie 的 process ps aux | grep melanie. 尋找包含樣本字元 strcpy 的 C 程式 grep 'strcpy' *.c 包含樣本字元的行號 grep –n ‘strcpy’ *.c 列出包含樣本字元的檔案名稱 grep –l ‘strcpy’ *.c

Download Presentation

grep 尋求特定字串

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. grep尋求特定字串 • 由標準輸入依照樣本字元逐行搜尋 • 只要包含所要的樣本字元都會印在標準輸出上 grep [-cilnv] pattern [filelist] • 找出以l開始的行列 ls -l /bin | grep \^l • 找出process中含有melanie的process ps aux | grep melanie

  2. 尋找包含樣本字元strcpy的C程式 • grep 'strcpy' *.c • 包含樣本字元的行號 • grep –n ‘strcpy’ *.c • 列出包含樣本字元的檔案名稱 • grep –l ‘strcpy’ *.c • 列出不包含樣本字元的所有列 • grep –v ‘strcpy’ out3.c

  3. sort • 輸出到標準輸出 • 以ASCII排序 • 控制字元 • 空白 • 數字 • 大寫字母 • 小寫字母 • 欄位是用空白來界定 • 欄位0為第一欄

  4. sort • -b 略過不對開頭的空白排序 • -f 大小寫字母一視同仁 • -n 依數字排序 • -M依月份順序;Jan < Feb < Mar • -d 依字典順序;忽略標點符號 • -r 反向排序

  5. sort by key filed • +n以第n欄為key • sort +1 telnos gmk 245-3209 arm 333-3903 kc 362-4993

  6. sort-c • 檢查是否己排序 • sun4330% sort -c telnos sort: disorder: gmk 245-3209

  7. sort -n • 比較數字 • sort -n numbs 5 40 300 2000 10000

  8. sort-o outflie • 將結果存到檔案中 • sort telnos > telnos(錯誤) • sort telnos > telnos.tmp mv telnos.tmp telnos • sort -o telnos telnos

More Related