It's a type of Planche
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

30 rindas
701B

  1. #!/usr/bin/env bash
  2. # ${0} is the script name so this will output
  3. # to the current directory as script_name.log
  4. LOG_FILE="./${0}.log"
  5. # Log all output to file
  6. # tee -a - append
  7. # tee -i - ignore interrupt signals
  8. # STDOUT
  9. exec > >(tee -ai ${LOG_FILE})
  10. # STDERR
  11. exec 2> >(tee -ai ${LOG_FILE})
  12. # Copy the username@hostname working directory
  13. # and command into the log file before the
  14. # command is run
  15. function echo_command () {
  16. # id -un - Output username
  17. # pwd - Print working directory
  18. # BASH_COMMAND - Command that's about to be run
  19. echo "$(id -un)@$(hostname) $(pwd) $ ${BASH_COMMAND}" >> ${LOG_FILE}
  20. }
  21. trap echo_command DEBUG
  22. date
  23. echo "Just echoed the date"
  24. date
  25. echo "Echoed it again"