亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 5382 | 回復(fù): 4
打印 上一主題 下一主題

sed替換的問題 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2010-12-28 09:55 |只看該作者 |倒序瀏覽
在鳥哥私房菜中有以下示例:
[root@www ~]# nl /etc/passwd | sed '2a drink tea'
1 root:0:0:root:/root:/bin/bash
2 bin:1:1:bin:/bin:/sbin/nologin
drink tea
3 daemon:2:2:daemon:/sbin:/sbin/nologin

在第二行后插入 drink tea
我在freebsd 6.2下怎么試都不行,提示如下:
%nl /etc/passwd | sed '2a drink tea'
sed: 1: "2a drink tea": command a expects \ followed by text

這個是什么問題,怎樣寫才是正確的?

另外把命令寫到文件里執(zhí)行沒問題
%cat change.sed
#!/usr/bin/sed -f
2 a\
drink tea

./change.sed /etc/passwd 這樣是正常的.

論壇徽章:
1
2015年辭舊歲徽章
日期:2015-03-03 16:54:15
2 [報告]
發(fā)表于 2010-12-28 10:01 |只看該作者
正規(guī)的模式應(yīng)該是a后面加一個\的。

可能還是gnu的改進的sed

論壇徽章:
0
3 [報告]
發(fā)表于 2010-12-28 10:08 |只看該作者
本帖最后由 zbhdpx 于 2010-12-28 10:12 編輯

以下在csh下邊試
%nl /etc/passwd | sed '2a\ drink tea'
sed: 1: "2a\ drink tea": extra characters after \ at the end of a command

我加了也是這樣,剛又試了一下,可能我用的是csh,


在sh下

# nl /etc/passwd | sed '2a\ drink tea'
sed: 1: "2a\ drink tea": extra characters after \ at the end of a command

# cat test.txt |sed '2c\
> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> '

HORSEFEATHERS SOFTWARE PRODUCT BULLETIN
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  of Horsefeathers  software products  --  Horsefeathers  Business
  BASIC, BASIC  Librarian,  and LIDO.  These software products can
  fill  your    requirements    for    powerful,    sophisticated,
  general-purpose business  software providing you with a base for
  software customization or development.


這樣是正常的,

論壇徽章:
1
2015年辭舊歲徽章
日期:2015-03-03 16:54:15
4 [報告]
發(fā)表于 2010-12-28 12:22 |只看該作者
本帖最后由 L_kernel 于 2010-12-28 18:22 編輯
以下在csh下邊試
%nl /etc/passwd | sed '2a\ drink tea'
sed: 1: "2a\ drink tea": extra characters af ...
zbhdpx 發(fā)表于 2010-12-28 10:08



    bash和bourne shell都不行。同樣是在bsd 8.1當中。
nl /etc/passwd | sed '2a\ drink tea'

論壇徽章:
0
5 [報告]
發(fā)表于 2010-12-28 17:25 |只看該作者
本帖最后由 zbhdpx 于 2010-12-28 17:29 編輯

%cat test.txt
The honeysuckle band played all night long for only $90.
Too bad the disco floor fell through at 23:10.
The local nurse Miss P.Neave was in attendance.

%cat test.txt | sed '2a\ \回車
? AAAAAAAAAAAAAAAAAAAA \回車
? '回車
The honeysuckle band played all night long for only $90.
Too bad the disco floor fell through at 23:10.
AAAAAAAAAAAAAAAAAAAA
The local nurse Miss P.Neave was in attendance.

在csh下,上邊的操作是可行的,但是插入內(nèi)容不多于一行
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP