一条sed命令的疑问
one.txt的内容为CODE:
one
two
three
two
three
执行
sed -e '1c eky' -e 'w two.txt' one.txt
two.txt的内容变成
CODE:
two
thre
thre
为什么不是
CODE:
eky
two
three
因为你使用的是c命令。
c文本"eky"不会放到pattern space里面。
sed '1s/.*/eky/;w two.txt'
`c\'
`TEXT'
Delete the lines matching the address or address-range, and output
the lines of text which follow this command (each but the last
ending with a `\', which are removed from the output) in place of
the last line (or in place of each line, if no addresses were
specified). A new cycle is started after this command is done,
since the pattern space will have been deleted.
two
three
因为你使用的是c命令。
c文本"eky"不会放到pattern space里面。
sed '1s/.*/eky/;w two.txt'
`c\'
`TEXT'
Delete the lines matching the address or address-range, and output
the lines of text which follow this command (each but the last
ending with a `\', which are removed from the output) in place of
the last line (or in place of each line, if no addresses were
specified). A new cycle is started after this command is done,
since the pattern space will have been deleted.