Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. # ID 1
  2. blah blah
  3. blah blah
  4. $ description 1
  5. blah blah
  6. # ID 2
  7. blah
  8. $ description 2
  9. blah blah
  10. blah blah
  11.  
  12. # ID 1
  13. $ description 1
  14. blah blah
  15. # ID 2
  16. $ description 2
  17. blah blah
  18. blah blah
  19.  
  20. sed '/^#/,/^$/{/^#/!{/^$/!d}}' file.txt
  21.  
  22. # ID 1
  23. $ description 1
  24. blah blah
  25. # ID 2
  26. $ description 2
  27. blah blah
  28. blah blah
  29.  
  30. $ cat test
  31. 1
  32. start
  33. 2
  34. end
  35. 3
  36. $ sed -n '1,/start/p;/end/,$p' test
  37. 1
  38. start
  39. end
  40. 3
  41. $ sed '/start/,/end/d' test
  42. 1
  43. 3
  44.  
  45. sed -n -e "1,/# ID 1/ p" -e "/$ description 1/,$ p"
  46.  
  47. sed '/^#/,/^$/{//!d;};' file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement