BASH   23

log rotate

Guest on 23rd November 2022 03:33:06 PM

  1. #! /bin/sh
  2.  
  3. set -ue
  4.  
  5. LOG="$1"
  6.  
  7. DATE=$(/bin/ls -l --time-style=long "${LOG}" \
  8.        | awk '{gsub("-",".",$6); print $6"-"$7}')
  9.  
  10. ## set -x
  11.  
  12. mv "${LOG}" "$(dirname "${LOG}")"/"$(basename "${LOG}" .log)"-${DATE}.log

Raw Paste


Login or Register to edit or fork this paste. It's free.