Created
March 22, 2017 15:35
-
-
Save alst74/588741676ab61123d9014bb2c3dcb5e2 to your computer and use it in GitHub Desktop.
Read a file (log) until the word elapsed occur (also print the file)
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/sh | |
EXPECTED_NO_LINES=1 | |
i=0 | |
echo "exp lines: ${EXPECTED_NO_LINES}" | |
echo "lines: ${ACTUAL_NO_LINES}" | |
while [ $i -eq 0 ]; do | |
ACTUAL_NO_LINES=$(cat asdf3.log | wc -l) | |
if ! [[ $ACTUAL_NO_LINES -eq $EXPECTED_NO_LINES ]]; then | |
sed -n "${EXPECTED_NO_LINES},${ACTUAL_NO_LINES}p" asdf3.log | |
EXPECTED_NO_LINES=$ACTUAL_NO_LINES | |
$(grep -q elapsed asdf3.log) && i=1 | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment