Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- menuentry ... {
- ....
- ....
- }
- ....
- menuentry ... {
- ....
- ....
- }
- cat $file | sed '/^menuentry.*{/!d;x;s/^/x/;/x{1}/!{x;d};x;:a;n;/^}/!ba;q'
- numEntries=$( egrep -c "^menuentry.*{" $file )
- for i in $( seq 1 $numEntries); do
- i=$( echo $i | tr -d 'n' ) # A google search indicated sed encounters problems
- # when a substituted variable has a trailing return char
- # Get the nth entry block of text with the sed statement from before,
- # but replace with variable $i
- entry=$( cat $file | sed '/^menuentry.*{/!d;x;s/^/x/;/x{$i}/!{x;d};x;:a;n;/^}/!ba;q')
- # Do some stuff with $entry #
- done
Add Comment
Please, Sign In to add comment