

下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、shell 段落注釋_shell,之重新格式化段落-重新格式化段落 大部分功能強大的文本編輯器都提供重新格式化段落的命令;供用戶切分段落,使文本行數(shù)不要超出我們看到的屏幕范圍。這樣我們就引入了 fmt 命令,雖然一些 fmt 的實現(xiàn)有較多的選項可用,但其實只用:-s 僅切割較長的行,但不會將短行結合成較長的行,而 -w n 則設置輸出行寬度為 n 個字符 (默認通常是 75 個)。 fmt 命令的語法: fmt option file-list fmt 通過將所有非空白的長度設置為幾乎相同,來進行簡單的文本格式化。 -s 截斷長行,但不合并 -t 除每個段落的第 1 行外都縮進 -u 改變格式
2、化,使字之間出現(xiàn)一個空格,句子之間出現(xiàn)兩個空格 -w n 將輸出的行寬改為 n 個字符。不帶該選項時,fmt 輸出的行寬度為 75 個字符 例如,我有一個文件 demo,內(nèi)容為:a long time ago, there was a huge apple tree.a little boy loved to come and play around it every day. he climbed to the tree top, ate the apples, took a nap under the shadow he loved the tree and the tree loved
3、to play with him.re使用命令 fmt -s demo,輸出為:a long time ago, there was a huge apple tree.a little boy lovedto come and play around it every day. he climbed to the tree top, atethe apples, took a nap under the shadow he loved the tree and thetree loved to play with him.re該命令的含義是節(jié)段 2 長行。 使用 fmt -t demo 命令
4、的意思是說排除首行的縮進,結果為:a long time ago, there was a huge apple tree. a little boy loved to come and play around it every day. he climbed to the tree top, ate the apples, took a nap under the shadow he loved the tree and the tree loved to play with him.re使用 fmt -u demo 命令的意思是說格式化單詞和句子的間隔。輸出為:a long time ag
5、o, there was a huge apple tree. a little boy loved to comeand play around it every day. he climbed to the tree top, ate the apples,took a nap under the shadow he loved the tree and the tree loved toplay with him.re顯然 a little boy 前面的多個空格變成了兩個。 使用命令 fmt -w 40 demo 意思是說指定行的寬度,這里的行寬為 40 個字符。所以輸出為:a lon
6、g time ago, there was a hugeapple tree. a little boyloved to come and play around itevery day. he climbed to the tree top,ate the apples, took a nap under theshadow he loved the tree and thetree loved to play with him.re僅作切割的選項: -s,在你想將長的行繞回,短的行保持不動時很好用,這么做也能使結果與原始版本間的差異達到最小,例如:fmt -s -w 10 eofone t
7、wo three four fivesixseveneight輸出為:one twothreefour fivesixseveneightrefmt 的小案例: 下面以拼音字典為例: 字典文件:/usr/dict/words 或者 /usr/share/dict/words。 sed -n -e 9991,10010p /usr/share/dict/words | fmt sed -n -e 9991,10010p /usr/share/dict/words | fmt -w 30 觀察上面兩行命令的輸出。 復習一下 sed 命令: sed 是一個很好的文件處理工具,本身是一個管道命令,主要
8、是以行為單位進行處理,可以將數(shù)據(jù)行進行替換、刪除、新增、選取等特定工作。假設我們有一個文件 demosed 1d demo 刪除第一行sed -n 1p 顯示第一行sed -n /root/p demo 查詢包括關鍵字 root 所在所有行sed 1a hahaha demo 第一行后增加字符串 hahahased 1,3a hahaha demo 第一行到第三行后增加字符串 hahahased 1c hihihi demo 第一行代替為 hihihised 1,2c hihihi demo 第一行和第二行替換為 hihihire替換一行中的某部分格式:sed s/ 要替換的字符串 / 新的字符串 /g ,案例:sed s/root/hahaha/g 替換 root 為 hahahased s/root/g 刪除 rootse
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 高效智能倉儲租賃服務協(xié)議
- 采礦權出讓與礦產(chǎn)資源保護責任書范本
- 礦山股權轉讓與礦區(qū)環(huán)境保護責任書
- 高端公寓短期租賃轉租服務協(xié)議
- 安全管理方針
- 是安全風險隱患排查治理的主體
- 防溺水安全教育安全教育
- 生產(chǎn)安全事故報告和調(diào)查處理條例自
- 礦山復工復產(chǎn)安全培訓
- 消防安全責任人任命書模板
- 中華人民共和國史期末復習
- 呼倫貝爾市國企招聘考試試題及答案2025
- 蘇教版 五年級 數(shù)學 下冊《第1課時 因數(shù)和倍數(shù)》課件
- 《解讀臨床醫(yī)學認證》課件
- 七八年級的英語單詞
- 全國高職高專院校信息素養(yǎng)大賽考試題及答案
- 2024年面向社會公開招聘警務輔助人員報名信息表
- 手術應激反應
- 《地區(qū)智能電網(wǎng)調(diào)度技術支持系統(tǒng)應用功能規(guī)范》
- 2024中國類風濕關節(jié)炎診療指南
- 11294營銷管理-國家開放大學2023年1月至7月期末考試真題及答案(共2套)
評論
0/150
提交評論