clipia.sh 503 B

12345678910111213141516171819
  1. #!/bin/bash
  2. # Wrapper for clipea that logs
  3. command="/home/gmj/bin/clipea"
  4. temp_logfile="/home/gmj/var/log/clipea.log.tmp"
  5. logfile="/home/gmj/var/log/clipea-`date +%Y-%m`.log"
  6. # Store the command line arguments
  7. args="$@"
  8. # Run the 'clipea' command with logging
  9. script -q -f -e -c "$command $args" "$temp_logfile"
  10. # Remove escape sequences and append to log
  11. cat "$temp_logfile" | \
  12. sed -r \ 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g;s/\x0D//g' \
  13. >> $logfile
  14. # Clean up
  15. rm $temp_logfile