Ask a Question related to UNIX Programming, Design and Development.
-
Christoph Kukulies #1
ed /pattern/ command
I want to edit a file in several places that contain a certain pattern.
file:
title
a
b
c
title
a
b
c
title
a
b
c
My command file:
#!/bin/sh
ed grub.conf <<EOF
/title/
a
password --md5 \$1\$Bg2gu/\$Zv3cGRU19XWCrU.963Cs71
..
w
q
EOF
How can I add the line after every occurence of "title" ?
Please cc me.
--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
Christoph Kukulies Guest
-
Invalid color: colored pattern specified withuncolored pattern colorspace.
Hi. Just installed Mac OS X 10.4 Tiger and note the following message flooding the system.log when using Acrobat Pro version 7.0.1. Apr 30... -
Acrobat 6.01: File Command disappears on Command Bar
On the Command Bar (File, Edit, View, etc.) the File Command disappears in many Acrobat operations. Is there a parameter available to insure that... -
RUN/execute a Command-Line command from an ASP page.
Hi, I need to RUN/execute a Command-Line command from an ASP page. This is the command: sse45.exe -i k:\o\2.wmv -o k:\o\2.shh -w 128 -df 0 -m 2... -
Windows Explorer Right Click Command (+ Custom Command Script)
Ok got a tricky question about custom scripts, I would like to add a Windows Explorer Right Click Command - that allows me to select an image/s... -
Multi command files and running them from the command prompt
Use the -td§ option . Details are in the section titled Command Line Processor Options in the Command Reference. "Derek Clarkson"... -
Christoph Kukulies #2
Re: ed /pattern/ command
Fletcher Glenn <fandmgiiNOSPAM@pacbell.net> wrote:
> "Christoph Kukulies" <kuku@accms33.physik.rwth-aachen.de> wrote in message
> news:bee0re$5de$1@nets3.rz.RWTH-Aachen.DE...>> I want to edit a file in several places that contain a certain pattern.
>>
>> file:
>>
>> title
>> a
>> b
>> c
>> title
>> a
>> b
>> c
>> title
>> a
>> b
>> c
>>
>> My command file:
>>
>> #!/bin/sh
>> ed grub.conf <<EOF
>> /title/
>> a
>> password --md5 \$1\$Bg2gu/\$Zv3cGRU19XWCrU.963Cs71
>> .
>> w
>> q
>> EOF
>>
>>
>> How can I add the line after every occurence of "title" ?
>>
>> Please cc me.
>>
>> --
>> Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
>>> Instead of the two lines:> /title/
> a> Try the following:probably I'd have to escape the $ from the shell.> g/title/s/$/^M password --etc/
Sure, that is all known but I tried to prepend the /title/ with a g(lobal)> The "g" command says "on every line containing the pattern".
> The "s" command says "substitute the second pattern for the first".
> $ is the end of the line.
and it didn't work. Why does it not work with the a(ppend) command?
Or is it that your solution is a one line command and mine is
spread over several lines? Could I pack the a(ppend) stuff in
a oneliner also?
Or typing ^V^M (control-V, control-M) (keyboard travel optimized :-)> ^M is produced by entering "control-V" followed by "return(or enter)".
Yes, I know that (^V escape)
Thanks.> You might also have to add another ^M to the end of the pattern.
--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
Christoph Kukulies Guest
-
Fletcher Glenn #3
Re: ed /pattern/ command
Christoph Kukulies wrote:
The 'g' command is only in effect for that one line. Any commands>
> Fletcher Glenn <fandmgiiNOSPAM@pacbell.net> wrote:
>>> > "Christoph Kukulies" <kuku@accms33.physik.rwth-aachen.de> wrote in message
> > news:bee0re$5de$1@nets3.rz.RWTH-Aachen.DE...> >> I want to edit a file in several places that contain a certain pattern.
> >>
> >> file:
> >>
> >> title
> >> a
> >> b
> >> c
> >> title
> >> a
> >> b
> >> c
> >> title
> >> a
> >> b
> >> c
> >>
> >> My command file:
> >>
> >> #!/bin/sh
> >> ed grub.conf <<EOF
> >> /title/
> >> a
> >> password --md5 \$1\$Bg2gu/\$Zv3cGRU19XWCrU.963Cs71
> >> .
> >> w
> >> q
> >> EOF
> >>
> >>
> >> How can I add the line after every occurence of "title" ?
> >>
> >> Please cc me.
> >>
> >> --
> >> Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
> >>>> > Instead of the two lines:>> > /title/
> > a>> > Try the following:>> > g/title/s/$/^M password --etc/
> probably I'd have to escape the $ from the shell.
>>> > The "g" command says "on every line containing the pattern".
> > The "s" command says "substitute the second pattern for the first".
> > $ is the end of the line.
> Sure, that is all known but I tried to prepend the /title/ with a g(lobal)
> and it didn't work. Why does it not work with the a(ppend) command?
>
> Or is it that your solution is a one line command and mine is
> spread over several lines? Could I pack the a(ppend) stuff in
> a oneliner also?
>>> > ^M is produced by entering "control-V" followed by "return(or enter)".
> Or typing ^V^M (control-V, control-M) (keyboard travel optimized :-)
>
> Yes, I know that (^V escape)
>>> > You might also have to add another ^M to the end of the pattern.
> Thanks.
>
> --
> Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
that follow the 'g' command are not affected by it.
--
Fletcher Glenn
email [email]f-g-l-e-n-n@quest.com[/email] (remove the dashes)
Fletcher Glenn Guest
-
Christoph Kukulies #4
Re: ed /pattern/ command
Fletcher Glenn <fandmgiiNOSPAM@pacbell.net> wrote:
> g/title/s/$/^M password --etc/> The "g" command says "on every line containing the pattern".
> The "s" command says "substitute the second pattern for the first".
> $ is the end of the line.
> ^M is produced by entering "control-V" followed by "return(or enter)".> You might also have to add another ^M to the end of the pattern.Indeed, my mileage varies. I'm getting ^M literally inserted rather> YMMV,
than a line feed.
--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
Christoph Kukulies Guest
-
Mark Wooding #5
Re: ed /pattern/ command
Fletcher Glenn <fandmgiiNOSPAM@pacbell.net> wrote:
Yeuch.> g/title/s/$/^M password --etc/
g/title/a\
password --whatever\
..
-- [mdw]
Mark Wooding Guest
-
Christoph Kukulies #6
Re: ed /pattern/ command
Mark Wooding <mdw@nsict.org> wrote:
> Fletcher Glenn <fandmgiiNOSPAM@pacbell.net> wrote:>> g/title/s/$/^M password --etc/> Yeuch.Hhmm. Doesn't work. Gives the typical> g/title/a\
> password --whatever\
> .
48
?
--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
Christoph Kukulies Guest
-
Mark Wooding #7
Re: ed /pattern/ command
Christoph Kukulies <kuku@accms33.physik.rwth-aachen.de> wrote:
How strange. I tested it on Linux and Solaris, so I doubt I've done> Hhmm. Doesn't work. Gives the typical
>
> 48
> ?
anything particularly weird. You remembered the backslash-newlines?
-- [mdw]
Mark Wooding Guest



Reply With Quote

