Created
March 22, 2017 14:44
-
-
Save XiaochenCui/c96fb81b7c53a6904517c3dc80fbdb71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LINE_NUMBER=${LINE_NUMBER:-1} | |
HEADER="" | |
ERROR_HEADER=("E" "F") | |
END_FLAG=false | |
print_message() { | |
if [ -n "$MESSAGE" ] | |
then | |
echo "Message:$MESSAGE" | |
fi | |
} | |
while read -r LINE; | |
do | |
if [[ $LINE =~ (^[IEF],) ]] | |
then | |
print_message | |
HEADER=${LINE:0:1} | |
MESSAGE="" | |
fi | |
if [[ " ${ERROR_HEADER[@]} " =~ " ${HEADER} " ]] | |
then | |
MESSAGE="$MESSAGE"$'\n'"$LINE" | |
fi | |
(( LINE_NUMBER += 1 )) | |
done <<< "$(sed -n $LINE_NUMBER',$p')" | |
export LINE_NUMBER=$LINE_NUMBER | |
print_message | |
echo $LINE_NUMBER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment