Created
March 16, 2018 15:02
-
-
Save aks/5f6f1226ef16c1460d9b32e9f5ac7400 to your computer and use it in GitHub Desktop.
Bash script to zero out all the log files in `~/log`. Useful for Rails apps.
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
| #!/usr/bin/env bash | |
| if [[ -d log ]] ; then | |
| set -- log | |
| while (( $# > 0 )) ; do | |
| file="$1" | |
| shift | |
| if [[ -f $file && -s $file ]] ; then | |
| case "$file" in | |
| *.log|*.txt|*.lst) | |
| echo " $file" | |
| cat /dev/null >$file | |
| ;; | |
| esac | |
| elif [[ -d $file ]]; then | |
| set -- "$@" $file/* | |
| fi | |
| done | |
| else | |
| echo "No log directory" | |
| fi | |
| exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment