Chris Fowler wrote:
>
> I'm trying to edit /etc/inittab and need to use sed. I have a question.
> How can I use sed to change off to respawn in only on occurence in this
> file.
>
> Below is an exapmle
>
> au00:234:off:/etc/getty /dev/ttyg00 m
> au01:234:off:/etc/getty /dev/ttyg00 m
>
> if I do the following:
>
> cat /etc/inittab | sed s/off/respawn > /tmp/inittab.tmp ; mv
> /tmp/inittab.tmp /etc/inittab
>
> then it will replace all occurence of off.
>
> How can I cahnge the above statement to change it on the line that just has
> au00
>
> Thanks,
> Chris
> --
> To unsubscribe: mail ">majordomo@ale.org with "unsubscribe ale" in message body.
My guess is to specify au00:234 explicitly. A more talented script
writer would copy each line to a buffer, grep the buffer input for
'au00' at the beginning, and sed the text that matches. I'm not that
good (yet).
I just noticed /s/off/respawn/g will do what you describe globally, but
do a 'man sed' under addresses:
\cregexpc
Match lines matching the regular expression regexp. The c may be any
character.
It appears you can specify the line number and replace regexp there only
and not globally.
- Scott
- Scott
--
Never do windows again with
__
/ / __ _ _ _ _ __ __
/ /__ / / / \// //_// \ \/ /
/____/ /_/ /_/\/ /___/ /_/\_\.
No streaking, haze, or glaze.
--
To unsubscribe: mail ">majordomo@ale.org with "unsubscribe ale" in message body.