Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- COUNT=0
- #Create two arrays, one for the start, one for the end
- START=($(grep -n Orange test.txt | awk -F: '{print $1}' | sed -e :a -e '$!N; s/\n/ /; ta' ))
- END=($(grep -n "\-\-\-\-$" test.txt | awk -F: '{print $1}' | sed -e :a -e '$!N; s/\n/ /; ta' ))
- # Find the last index of the array(subtract 1)
- let ARRAY_END=${#START[*]}-1
- while [ $COUNT -le $ARRAY_END ]
- do
- # get start of print
- let ACTUAL=${START[$COUNT]}-2
- let STOP=${END[$COUNT]}+0
- sed -n "$ACTUAL,${STOP}p" test.txt
- let COUNT=$COUNT+1
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement