Advertisement
wreiner

sed block comment out

Jun 6th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.46 KB | None | 0 0
  1. Block to comment out - cat xxx:
  2. <Location /123>
  3. ich
  4. bin
  5. text
  6. </Location>
  7.  
  8. #-----------------------------------------
  9.  
  10. Script with error:
  11.  
  12. #!/bin/bash
  13.  
  14. loc="/123"
  15. sed -i "/<Location $loc>/,/<\/Location>/s/^/#/" xxx
  16.  
  17. sed -i "\:<Location $loc>:,:</Location>:s:^:#:" xxx
  18.  
  19. #-----------------------------------------
  20.  
  21. Working Script:
  22.  
  23. #!/bin/bash
  24.  
  25. loc="/123"
  26. sed "\:<Location $loc>:,\:</Location>:s:^:#:" xxx
  27.  
  28. # The second \ after the , was missing.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement