Guest User

Untitled

a guest
Feb 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. menuentry ... {
  2. ....
  3. ....
  4. }
  5.  
  6. ....
  7.  
  8. menuentry ... {
  9. ....
  10. ....
  11. }
  12.  
  13. cat $file | sed '/^menuentry.*{/!d;x;s/^/x/;/x{1}/!{x;d};x;:a;n;/^}/!ba;q'
  14.  
  15. numEntries=$( egrep -c "^menuentry.*{" $file )
  16. for i in $( seq 1 $numEntries); do
  17.  
  18. i=$( echo $i | tr -d 'n' ) # A google search indicated sed encounters problems
  19. # when a substituted variable has a trailing return char
  20.  
  21. # Get the nth entry block of text with the sed statement from before,
  22. # but replace with variable $i
  23. entry=$( cat $file | sed '/^menuentry.*{/!d;x;s/^/x/;/x{$i}/!{x;d};x;:a;n;/^}/!ba;q')
  24.  
  25. # Do some stuff with $entry #
  26.  
  27. done
Add Comment
Please, Sign In to add comment