Skip to content

Instantly share code, notes, and snippets.

@Kineolyan
Created June 6, 2018 11:47
Show Gist options
  • Save Kineolyan/95491fb81e265ccc23508cc325738159 to your computer and use it in GitHub Desktop.
Save Kineolyan/95491fb81e265ccc23508cc325738159 to your computer and use it in GitHub Desktop.
Smart bash pipe keeping the last line
function t() {
for e in $(echo 'ab ac ad e bc bd e cd')
do
echo $e
sleep 1
done
}
t | while read line;
do
if [[ $line == e ]]
then
echo "-- new line --"
else
echo -en " -> $line\r"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment