zono

Function for clear log files.

Sep 24th, 2011
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.33 KB | None | 0 0
  1. #!/bin/bash
  2. # This function assumes file name
  3. # as a argument and if exists
  4. # truncate it content and show
  5. # success message
  6. # Example of usage:
  7. # clearLogFile "fileName.txt"
  8. function clearLogFile {
  9.  if [ -e $1 ]
  10.  then
  11.    cat /dev/null > $1
  12.    echo "Log file ${1} is cleared."
  13.  else
  14.    echo "File ${1}  don't exists"
  15.  fi
  16. }
Advertisement
Add Comment
Please, Sign In to add comment