Skip to content

Instantly share code, notes, and snippets.

@atomize
Created November 11, 2018 22:13
Show Gist options
  • Save atomize/57c1585e1a17ceb16bc8994be6b21d96 to your computer and use it in GitHub Desktop.
Save atomize/57c1585e1a17ceb16bc8994be6b21d96 to your computer and use it in GitHub Desktop.
Set the PS4 variable, which is evaluated for every command being executed just before the execution if trace is on.
#!/bin/bash
#You can set the PS4 variable, which is evaluated for every command being executed just before the execution if trace is on:
PS4='$(echo $(date) $(history 1) >> /tmp/trace.txt) TRACE: '
#Then, enable trace:
set -x
#To stop tracing, just:
#set +x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment