You can use watch -d or –differences=permanent to highlight the differences between successive updates. If the optional permanent argument is specified then watch will show all changes since the first iteration.
Example:
Create and execute a script that inserts one new line every 2 seconds indefinitely.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
## create and execute a script that inserts one new line every 2 seconds indefinitely. cat << 'EOF' > myscript.sh #!/bin/bash > myfile i=1; while : do echo "$i" >> myfile sleep 2 ((i++)) done EOF ## execute the script in the background chmod +x myscript.sh ./myscript.sh & |
Example of watch -d or –differences=permanent option:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
## deafult watch tail myfile ## watch -d option watch -d tail myfile ## highlight differences between successive updates ## watch --differences=permanent option watch --differences=permanent tail myfile ## highlight what changed at least once since first iteration pkill -f "myscript.sh" ## kill myscript.sh rm my* |