Skip to content

Instantly share code, notes, and snippets.

@jwliechty
Created October 4, 2012 13:58
Show Gist options
  • Save jwliechty/3833693 to your computer and use it in GitHub Desktop.
Save jwliechty/3833693 to your computer and use it in GitHub Desktop.
Continually touches a file
#!/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"
@jwliechty
Copy link
Author

Continually touch a file or directory until the script is interrupted 'CTRL-C'

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