Created
October 4, 2012 13:58
-
-
Save jwliechty/3833693 to your computer and use it in GitHub Desktop.
Continually touches a file
This file contains 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 | |
DIR="/home/someone/somedir" | |
FILE="${1:?"First argument must be the filename name"}" | |
COUNT=1 | |
FILE_TO_TOUCH="${DIR}/${FILE}" | |
handleTrap(){ | |
echo -e "\n\nTouched '${FILE_TO_TOUCH}' ${COUNT} times." | |
exit 0 | |
} | |
trap handleTrap INT TERM | |
while touch "${FILE_TO_TOUCH}"; do | |
COUNT=$((COUNT+1)) | |
done | |
echo "Touch command failed out after ${COUNT} invocations" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Continually touch a file or directory until the script is interrupted 'CTRL-C'