Skip to content

Instantly share code, notes, and snippets.

@Razikus

Razikus/timetochange.sh

Last active May 17, 2018
Embed
What would you like to do?
To anyone who waits for output change and anyone who wants to calculate estimated time
#!/bin/bash
COMMAND=$@
SECOND="FALSE"
if [ "$1" == "--second" ]; then
SECOND="TRUE"
COMMAND=${@:2}
fi
OUTPUT=$($COMMAND)
NEWOUTPUT=$OUTPUT
a=0
while [ "$OUTPUT" == "$NEWOUTPUT" ]
do
sleep 0.01
a=$(echo "$a + 0.01" | bc)
NEWOUTPUT=$($COMMAND)
done
if [ "$SECOND" == "FALSE" ]; then
wdiff -3 <(echo "$OUTPUT" ) <(echo "$NEWOUTPUT" )
echo "$a seconds"
else
$0 $COMMAND
fi
@Razikus

This comment has been minimized.

Copy link
Owner Author

@Razikus Razikus commented May 17, 2018

Example usage:
timetochange --second du -sh /file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment