Last active
May 17, 2018 07:39
-
-
Save Razikus/05e742c9a0ec6ddebbb19d47a929c178 to your computer and use it in GitHub Desktop.
To anyone who waits for output change and anyone who wants to calculate estimated time
This file contains hidden or 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 | |
| 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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example usage:
timetochange --second du -sh /file