From: moonhkt on 16 Apr 2010 12:13 Hi all When add for replace next is blank line. Not work. How to fix this problem ? /^$/ { N /^\n$/D } #!/bin/ksh # sed_del.ksh # 2010/04/16 sed '/^Delete Database/d /^end of message/d /^$/ { N /^\n$/D } ' sed.text sed.text sample file /* testing_email_body.txt */ UNIX SILENT cat /phx/src/testing_email_body.txt \> end of message Delete Database My output $ sed_del.ksh /* testing_email_body.txt */ UNIX SILENT cat /phx/src/testing_email_body.txt \> end of message Delete Database
From: Ed Morton on 16 Apr 2010 12:23 On 4/16/2010 11:13 AM, moonhkt wrote: > Hi all > > When add for replace next is blank line. Not work. How to fix this > problem ? > /^$/ { > N > /^\n$/D > } sed is an excellent tool for simple substitutions on a single line. For anything else you should use awk, perl, etc. Now, tell us what you're trying to do, with a small sample input and the expected output from that input (not the output some script that didn't work gives you as that's not useful), and one of us will show you a very clear, simple awk script that does it. Ed.
From: moonhkt on 16 Apr 2010 23:25 On 4æ17æ¥, ä¸å12æ23å, Ed Morton <mortons...(a)gmail.com> wrote: > On 4/16/2010 11:13 AM, moonhkt wrote: > > > Hi all > > > When add for replace next is blank line. Not work. How to fix this > > problem ? > >   /^$/ { > >       N > >       /^\n$/D > >   } > > sed is an excellent tool for simple substitutions on a single line. For anything > else you should use awk, perl, etc. > > Now, tell us what you're trying to do, with a small sample input and the > expected output from that input (not the output some script that didn't work > gives you as that's not useful), and one of us will show you a very clear, > simple awk script that does it. > >    Ed. Does sed can substitution/delete as below ? I am read a book, "sed & awk" , O'Reilly also Perl. When using two sed, the result is ok sed '/^Delete Database/d /^end of message/d ' sed.text | sed '/^$/{ N /^\n$/D } ' Input file ====== $ cat sed.text /* testing_email_body.txt */ UNIX SILENT cat /phx/src/testing_email_body.txt \> end of message Delete Database line 9 Output file ======= /* testing_email_body.txt */ UNIX SILENT cat /phx/src/testing_email_body.txt \> line 9
From: Janis Papanagnou on 16 Apr 2010 23:58 moonhkt schrieb: > On 4月17日, 上午12時23分, Ed Morton <mortons...(a)gmail.com> wrote: >> On 4/16/2010 11:13 AM, moonhkt wrote: >> >>> Hi all >>> When add for replace next is blank line. Not work. How to fix this >>> problem ? >>> [...] >> sed is an excellent tool for simple substitutions on a single line. For anything >> else you should use awk, perl, etc. >> >> Now, tell us what you're trying to do, with a small sample input and the >> expected output from that input (not the output some script that didn't work >> gives you as that's not useful), and one of us will show you a very clear, >> simple awk script that does it. >> >> Ed. > > Does sed can substitution/delete as below ? I am read a book, "sed & > awk" , O'Reilly also Perl. > > > When using two sed, the result is ok > [...] If you prefer to ignore Ed's suggestions then it's as well fine to stick with what you have using two seds since it works, don't you think? Janis
From: Ed Morton on 17 Apr 2010 09:06 On 4/16/2010 10:25 PM, moonhkt wrote: > On 4月17日, 上午12時23分, Ed Morton<mortons...(a)gmail.com> wrote: >> On 4/16/2010 11:13 AM, moonhkt wrote: >> >>> Hi all >> >>> When add for replace next is blank line. Not work. How to fix this >>> problem ? >>> /^$/ { >>> N >>> /^\n$/D >>> } >> >> sed is an excellent tool for simple substitutions on a single line. For anything >> else you should use awk, perl, etc. >> >> Now, tell us what you're trying to do, with a small sample input and the >> expected output from that input (not the output some script that didn't work >> gives you as that's not useful), and one of us will show you a very clear, >> simple awk script that does it. >> >> Ed. > > Does sed can substitution/delete as below ? I am read a book, "sed& > awk" , O'Reilly also Perl. Yes, and so can programs written in Assembly Code. There's several books on that available too. The point is just because you CAN do something doesn't mean you SHOULD do it. Ed.
|
Next
|
Last
Pages: 1 2 3 Prev: Calling readline functions from a bash script Next: interactive macro in vi |