原帖由 "cloudxx" 發(fā)表:
這里的{1,\}不太理解 誰(shuí)可解釋下?
原帖由 "admirer" 發(fā)表:
表示前面的正則表達(dá)式的一個(gè)或多個(gè)組合。
原帖由 "seacaptain" 發(fā)表:
老大
echo 20030922|sed 's/\(....\)\(..\)\(..\)/\1 \2 \3/'|read year month day
echo $year $month $day
這個(gè)代碼執(zhí)行沒(méi)有任何結(jié)果???
原帖由 "admirer" 發(fā)表:
文件內(nèi)容倒序輸出
代碼:
sed '1!G;h;$!d' oldfile >newfile
2.2.2 有那些函數(shù)(function)參數(shù)
下頁(yè)表中介紹所有 sed 的函數(shù)參數(shù)(參照[chapter 4])的功能。
函數(shù)參數(shù) 功能
: label 建立 script file 內(nèi)指令互相參考的位置。
# 建立解
{ } 集合有相同位址參數(shù)的指令。
! 不執(zhí)行函數(shù)參數(shù)。
= 印出資料行數(shù)( line number )。
a\ 添加使用者輸入的資料。
b label 將執(zhí)行的指令跳至由 : 建立的參考位置。
c\ 以使用者輸入的資料取代資料。
d 刪除資料。
D 刪除 pattern space 內(nèi)第一個(gè) newline 字母 \ 前的資料。
g 拷貝資料從 hold space。
G 添加資料從 hold space 至 pattern space 。
h 拷貝資料從 pattern space 至 hold space 。
H 添加資料從 pattern space 至 hold space 。
l 印出 l 資料中的 nonprinting character 用 ASCII 碼。
i\ 插入添加使用者輸入的資料行。
n 讀入下一筆資料。
N 添加下一筆資料到 pattern space。
p 印出資料。
P 印出 pattern space 內(nèi)第一個(gè) newline 字母 \ 前的資料。
q 跳出 sed 編輯。
r 讀入它檔內(nèi)容。
s 替換字串。
t label 先執(zhí)行一替換的編輯指令 , 如果替換成功,則將編輯指令跳至 : label 處執(zhí)行。
w 寫(xiě)資料到它檔內(nèi)。
x 交換 hold space 與 pattern space 內(nèi)容。
y 轉(zhuǎn)換(transform)字元。
歡迎光臨 Chinaunix (http://72891.cn/) | Powered by Discuz! X3.2 |