Find the answer to your Linux question:
Results 1 to 3 of 3
I was wondering if there is a single line sed command to delete lines of text between 2 characters. For example, between /* and */ in a java/c source code. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2005
    Posts
    3

    Sed command to delete between 2 points


    I was wondering if there is a single line sed command to delete lines of text between 2 characters. For example, between /* and */ in a java/c source code. I try sed '/[/*]/,/[*/]/d' but it only deletes odd parts of the code. I thought that the above meant delete between */ and */ but it doesnt work. Any advice or help would be appreciated. Thanks

  2. #2
    Linux Engineer
    Join Date
    Sep 2003
    Location
    Knoxhell, TN
    Posts
    1,078
    try this:
    Code:
    sed -e '/\/\*/,/\*\//d'
    the regex you were using meant 'delete lines between any line containing a '/' or a '*' and lines containing a '*' or '/''
    Their code will be beautiful, even if their desks are buried in 3 feet of crap. - esr

  3. #3
    Just Joined!
    Join Date
    Apr 2005
    Posts
    3
    Thank you very much. Now I understand what I was doing wrong.

Posting Permissions

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