I have a log file and I have two unique strings which represent the start and end of the text I want to obtain.
How can I get all the text inbetween this start string and the end string?
Thanks
I have a log file and I have two unique strings which represent the start and end of the text I want to obtain.
How can I get all the text inbetween this start string and the end string?
Thanks
#!/bin/bash
# tested on bash 4
declare -i toggle=0
while read -r line
do
case "$line" in
*start*)
toggle=1
line="${line#start}"
;;
*end*)
toggle=0
line="${line%end*}"
;;
esac
if [ $toggle -eq 1 ];then
echo "$line"
fi
done <file
awk '/start_string/, /stop_string/' file