[Ilugc] using sed

  • From: chaks.yoper@xxxxxxxxx (Chakkaradeep C C)
  • Date: Wed Apr 5 10:22:35 2006

Hi all,

On 4/4/06, Chakkaradeep C C <chaks.yoper@xxxxxxxxx> wrote:


Hi all,

On 4/4/06, Ramkumar R <andyetitmoves@xxxxxxxxx> wrote:

I tried, sed -e 's/GraphicalTheme=/GraphicalTheme=<my-theme>/ gdm.conf',
but
the line does not change here.Only the pattern changes.

sed -e 's/\s*GraphicalTheme\s*=.*/GraphicalTheme=foobar/' gdm.conf


Thanks a lot!, it worked. But where did you manage to get these commands
of sed?...am googling but am not able to get a gud tutorial of sed
commands....

Now am stuck up with another command...

I want to enable xdcmp flag Enable to true in gdm.conf. What i do, i get
all lines between the words "[xdmcp]" and "HonorIndirect=", and try to
replace that Enable line to Enable=true in those lines. I managed to get
help from http://sed.sourceforge.net/sedfaq4.html#s4.20 as how to get all
line between the words "from" to "until" and replace. But unfortunately it
seems to be not working...no idea why...here is the command,

sed -e '/[xdmcp]/,/HonorIndirect=/ { s/\<\Enable=\>/Enable=false/g }'
/etc/X11/gdm/gdm.conf

any idea how to make it work?


I have got some idea now. I get the line number of the [xdmcp] in the
gdm.conf using the commands,

grep -n -F "[xdmcp]" /etc/X11/gdm/gdm.conf | awk -F: '{print $1}'

i get 177

So now, if i do a sed like this,

sed -e '177,190 s/Enable=.*/Enable=true/;' /etc/X11/gdm/gdm.conf > gdm.new

It works perfect !. Now am not able to pass this 177 to sed as a variable. I
tried all kinds of tips and tricks as given here
http://sed.sourceforge.net/sedfaq4.html#s4.23 , but am not able to arrive at
the proper result.

Have anybody tried passing variables as commands to sed?

Thanks in advance.

Thanks in advance.

the operational part of the change is the .* at the end. those \s* may
be necessary for parsing any legal gdm.conf in particular.

--
April 1: This is the day upon which we are reminded of
what we are on the other three hundred and sixty-four.
          -- Mark Twain, "Pudd'nhead Wilson's Calendar"




--
Regards,
C.C.Chakkaradeep,
Novatium Solutions Limited,Chennai.
http://www.novatium.com
http://www.yoper.com

--
"Sometimes it's better not to ask - or to listen - when people tell you
something can't be done. I didnt ask for permission or approval. I just went
ahead and did it."  - from "Direct from Dell"




--
Regards,
C.C.Chakkaradeep,
Novatium Solutions Limited,Chennai.
http://www.novatium.com
http://www.yoper.com

--
"Sometimes it's better not to ask - or to listen - when people tell you
something can't be done. I didnt ask for permission or approval. I just went
ahead and did it."  - from "Direct from Dell"

Other related posts: