Find the answer to your Linux question:
Results 1 to 4 of 4

Thread: sed command

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    May 2005
    Chennai,TamilNadu, India

    sed command

    I am trying to use the sed command but i am facing a problem when trying to replace a string containing a slash "/"

    for eg:

    sed '/LABEL=//s// LABEL=/ elevator=deadline/g' $GRUB > $GRUBTEMP

    if u notice i am trying to replace the word "LABEL=/" with "LABEL=/ elevator=deadline"
    but since the slash character comes at the end of the character it is showing an error.
    is there any way of trying to interpret the slash character as part of the word????
    if so i would like to know

    Since i implemented this without sed by doing a round about method of reading the whole file and doing this

    any one has any ideas?

    I would also like to know how to append a text to the end of a particular line using sed? i tried the a\ option but it showed me an error

    sed '/PATTERN/a\

    This show i wrote it. the error i got was the the 'A' character in the appended line is not a command...

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    St. Petersburg, FL
    1. Try using a different delimiter than /:
    sed s:foo:bar:
    or try escaping / with a '\'
    2. Enclose the "APPENDED TEXT" in quotes

  3. #3
    Er, the APPENDED TEXT is already in quotes (single ones). Did you leave a space after the a\ - that would cause an error. The backslash has to be the last character on the line.

  4. $spacer_open
  5. #4
    Linux Newbie
    Join Date
    May 2005
    Chennai,TamilNadu, India
    yes it worked for me now.
    i just gave the single quotes and i checked with out the space.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts