1 / 10

Unix 指令 3

Unix 指令 3. 檔案搜尋. grep 在檔案中搜尋某一特定字串 參數說明 - i 忽略大小寫 -n 列出行號 -v 將不含某個字樣的行列出 範例 grep “My” file1 file2 find 某個目錄下開始一層層找檔案 語法 find 路徑 –name 檔名 範例 find html –name index.htm. 練習. 搜尋 OS/user.txt(sid.txt) 檔案內容,找出自己 登入帳號 並印出其行號。 回到上一層 ( 帳號的 home directory) , 尋找 user.txt(sid.txt) 檔案。.

matteo
Download Presentation

Unix 指令 3

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. Unix指令3

  2. 檔案搜尋 • grep • 在檔案中搜尋某一特定字串 • 參數說明 • -i忽略大小寫 • -n列出行號 • -v將不含某個字樣的行列出 • 範例 grep “My” file1 file2 • find • 某個目錄下開始一層層找檔案 • 語法 find 路徑 –name 檔名 • 範例 find html –name index.htm

  3. 練習 • 搜尋OS/user.txt(sid.txt)檔案內容,找出自己登入帳號並印出其行號。 • 回到上一層(帳號的home directory),尋找user.txt(sid.txt)檔案。

  4. 壓縮指令 • compress (原始檔會不見) • Unix的標準壓縮程式,用來將一個檔案壓縮 • 副檔名.Z • 壓縮語法 compress filename 或 解壓縮compress –d filename • uncompress • Unix的標準解壓縮程式 • 語法 uncompress filename.Z • gzip • GNU出的,取代了 compress,支援度佳的壓縮指令 • 副檔名 .gz • 壓縮語法 gzip filename或 解壓縮語法 gzip –d filename.gz • bzip2 • 比 gzip壓縮比更好 • 副檔名 .bz2 • 壓縮語法 bzip2 filename或 解壓縮語法 bzip2 –d filename.bz2

  5. 壓縮指令 • tar • 檔案的打包與壓縮 • 建立、解壓縮與查閱的參數 • -c建立一個打包(壓縮)檔案的參數指令(create) • -x解開一個包裹(壓縮)檔案的參數指令 • -t查看tarfile裡面的檔案 • 是否進行壓縮的參數 • -j使用bzip2 壓縮/解壓縮 • -z使用gzip壓縮/解壓縮 • 其他重要參數 • -p保持檔案原有的屬性/權限 • -v查閱打包過程的資訊 • -f file後續處理的檔名 • 語法 tar [-參數]f 打包檔 原始檔

  6. 練習 • 回到上一層(帳號的home directory) • 將OS目錄壓縮成abc.tar • 查看abc.tar壓縮檔內容

  7. vi編輯器 • 開(新)檔案 vi filename • 分為三種模式 • 一般模式 • 編輯模式 • 指令模式

  8. vi編輯器

  9. 練習 • 將「線上使用者清單」寫入test.txt新檔 • 利用vi編輯test.txt文字檔 • 將自己的學號插入於第3行 • 將第4、5行資料刪除 • 將第3行學號複製到最後一行 • 存檔離開 • 查看test.txt內容

  10. pico編輯器 • 開(新)檔案 • pico filename • 常用指令說明 • ctrl +g (get help) • pico的輔助說明檔----對pico的用法有不懂之處,就可查此說明檔。 • ctrl +x (exit) • 離開pico----當你編輯好後,按此指令就可離開pico編輯畫面。 • 當按了 ^x 後,會先出現下列這一行: Save modified buuffer (ANSWERING  " No " WILL DESTROY CHANGES ) ?問你是否要存檔,如果要則按y,反之按n。

More Related