learn Linux sed command
生活随笔
收集整理的這篇文章主要介紹了
learn Linux sed command
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
learn Linux sed command一、參考文檔:1. sed命令詳解http://qifuguang.me/2015/09/21/sed%E5%91%BD%E4%BB%A4%E8%AF%A6%E8%A7%A3/2. linux之sed用法http://www.cnblogs.com/dong008259/archive/2011/12/07/2279897.html3. Sed 的man手冊參數詳細解釋(一)http://blog.csdn.net/imfinger/article/details/6071175
二、sed命令的使用規則是這樣的:sed [option] 'command' input_file三、options:-n, --quiet, --silentsuppress automatic printing of pattern space-e script, --expression=scriptadd the script to the commands to be executed如果命令行上只有一個指令的時候可以不用寫-e,但是如果有多個指令的話一定要在每個指令的前面加-e選項。-f script-file, --file=script-fileadd the contents of script-file to the commands to be executed這里貌似是前面對應的-e對應的腳本--follow-symlinksfollow symlinks when processing in place-i[SUFFIX], --in-place[=SUFFIX]edit files in place (makes backup if extension supplied)-l N, --line-length=Nspecify the desired line-wrap length for the `l' command--posixdisable all GNU extensions.-r, --regexp-extendeduse extended regular expressions in the script.-s, --separateconsider files as separate rather than as a single continuouslong stream.-u, --unbufferedload minimal amounts of data from the input files and flush theoutput buffers more often--helpdisplay this help and exit--versionoutput version information and exit四、command有以下幾種:a \: append即追加字符串, a \的后面跟上字符串s(多行字符串可以用\n分隔),則會在當前選擇的行的后面都加上字符串s;c \: 取代/替換字符串,c \后面跟上字符串s(多行字符串可以用\n分隔),則會將當前選中的行替換成字符串s;d : delete即刪除,該命令會將當前選中的行刪除;i \: insert即插入字符串,i \后面跟上字符串s(多行字符串可以用\n分隔),則會在當前選中的行的前面都插入字符串s;p : print即打印,該命令會打印當前選擇的行到屏幕上;s : 替換,通常s命令的用法是這樣的:1,2s/old/new/g,將old字符串替換成new字符串
?
總結
以上是生活随笔為你收集整理的learn Linux sed command的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 不要哭
- 下一篇: linux 中/proc 详解