Re: sed vs gnu sed

看板FB_questions作者時間14年前 (2011/11/10 08:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/6 (看更多)
On 11/09/11 05:30, Vincent Hoffman wrote: > 'Hi all, > I'm trying to move a script from a linux box to a freebsd box. > All going well as its just a bash script and bash is bash, however there > is one line I'm unable to use directly, as bsd sed (correctly according > to SUS at least, I believe[1]) appends a newline when writing to > standard out, gnu sed doesnt. example > BSD > [backup@banshee ~]$ echo -n "/boot:7:1:5; /:7:1:5; /var:7:1:5" | sed -n > 's/[[:space:]]*;[[:space:]]*/;/gp' > /boot:7:1:5;/:7:1:5;/var:7:1:5 > [backup@banshee ~]$ > > LINUX > > [backup@amber ~]$ echo -n "/boot:7:1:5; /:7:1:5; /var:7:1:5" | sed > 's/[[:space:]]*;[[:space:]]*/;/g' > /boot:7:1:5;/:7:1:5;/var:7:1:5[backup@amber ~]$ > > is there any easy way to make our sed do the same as gnu sed here? > You could also just lop off the newline with tr -d '\n': echo -n "/boot:7:1:5; /:7:1:5; /var:7:1:5" | sed -n 's/[[:space:]]*;[[:space:]]*/;/gp' | tr -d '\n' _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
文章代碼(AID): #1Eknk2yT (FB_questions)
文章代碼(AID): #1Eknk2yT (FB_questions)