Received: by 10.180.82.226 with SMTP id l2mr654352wiy.1.1348233524414; Fri, 21 Sep 2012 06:18:44 -0700 (PDT) Path: q11ni9075749wiw.1!nntp.google.com!feeder3.cambriumusenet.nl!feeder1.cambriumusenet.nl!feed.tweaknews.nl!216.40.29.245.MISMATCH!novia!news-in-01.newsfeed.easynews.com!news-in-04.newsfeed.easynews.com!easynews.com!easynews!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.news.ucla.edu!nntp.club.cc.cmu.edu!feeder.erje.net!news1.as3257.net!draco.tiscalinet.it!news-f2.tiscali.it!not-for-mail From: Lem Novantotto Subject: Re: sed multiple -e pattern match problem Newsgroups: comp.unix.shell Reply-To: le...@people.it References: <529d3b82-b4eb-4af5-9288-a53437537218@n9g2000yqn.googlegroups.com> <201209141712262493@webuse.net> <50536bcf$0$1587$5fc30a8@news.tiscali.it> <201209141758432493@webuse.net> X-Face: '*{O=FR{|;Ot1.X_@;4{`a1]Or*9c9}*@9`.O#:ZJt!ou@,?9Y@oFg)l$:T8UGtiTUo\[D~|`e8w!VqLVb5e2SUNAyM+Rqr{oI8GjuRdyzk2US,(hLDWI-T%b7daZ?S"H"_pNqS;vNn@`~kpl46q92wYog~vrV3G(ZA.@UEI!r:u>TEFfWn}y''DU-(9m\^8HDf5#eK?G~gSPt%Bff;57-vw;z%qCc=}{{xiLm2m:OwdG-RTO}nL_]m6ZBk<~iH+bSd&Z+y{?m]@:H6K[sb Organization: Tiscali SpA NNTP-Posting-Host: 84.220.111.125 X-Trace: 1347650004 news.tiscali.it 1587 84.220.111.125:49823 X-Complaints-To: abuse@tiscali.it Bytes: 2966 X-Received-Bytes: 3125 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ed Morton ha scritto: [...] Just for the sake of my curiosity: > $ echo "abc-def" | sed 's/-/\n/' > abcndef On my system (linux with bash) this one works as expected: $ echo "abc-def" | sed 's/-/\n/' abc def However I've been told that, with sed, if you want to search a newline '\n' is good, but if you want to substitute a newline, you'd better use '\[ENTER]'. Maybe this works on your system too: $ echo "abc-def" | sed 's/-/\ > /' abc def > $ x="foo >> bar" > > $ echo "abc-def" | sed "s/-/$x/" > sed: -e expression #1, char 7: Unterminated `s' command > $ echo "abc-def" | sed 's/-/'"$x"'/' > sed: -e expression #1, char 7: Unterminated `s' command I've been able to make it work, on my system, only using '\n': $ x="foo\nbar" $ echo "abc-def" | sed "s/-/$x/" abcfoo bardef which, by the way, seems in contradiction with what I've just written about substitutions - and shouldn't work on your system. I don't think there's a way to do it quoting the sed command: to succesfully use a real newline, you should work in single quotes, but single quotes prevent variable expansion, so... You're right: surely awk behaviour looks more straightforward. :) -- Bye, Lem Ceterum censeo ISLAM esse delendum _________________________________________________________________ Non sprecare i cicli idle della tua CPU, né quelli della tua GPU. http://www.worldcommunitygrid.org/index.jsp http://www.rnaworld.de/rnaworld/ http://home.edges-grid.eu/home/ http://www.gpugrid.net/