Skip to content

Instantly share code, notes, and snippets.

@alst74
Created March 22, 2017 15:35
Show Gist options
  • Save alst74/588741676ab61123d9014bb2c3dcb5e2 to your computer and use it in GitHub Desktop.
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)
#!/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