Find the answer to your Linux question:
Results 1 to 3 of 3
hi! how can i add a comment to specific line with sed?...
  1. #1
    Just Joined!
    Join Date
    Feb 2010
    Posts
    28

    sed question

    hi! how can i add a comment to specific line with sed?

  2. #2
    Just Joined!
    Join Date
    Feb 2005
    Posts
    14
    Read the sed man page about addressing particular lines.
    Code:
    sed '1s/xxx/yyy/'

  3. #3
    Just Joined!
    Join Date
    Jul 2010
    Posts
    7
    Or, more explicitly, if you're trying to add a comment to the end of a line, and the comment symbol is a pound, try

    Code:
    sed "line#s/$/ # comment/" file1 > file2
    where "line#" above is of course the number of the line you're trying to add a comment to and should be replaced by a number.

Posting Permissions

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