bash -x script.sh 2> log

Run a bash script in debug mode, show output and save it on a file


4
2009-06-08 19:31:51

3 Alternatives + Submit Alt


  • 25
    bash -x ./post_to_commandlinefu.sh
    nottings · 2009-02-25 19:10:21 7
  • Sends both stdout and stderr to the pipe which captures the data in the file 'out.test' and sends to stdout of tee (likely /dev/tty unless redirected). Works on Bourne, Korn and Bash shells.


    4
    bash -x test.sh 2>&1 | tee out.test
    arcege · 2009-09-03 17:10:44 0
  • Display commands and their arguments as they are executed. Useful for debugging shell scripts. Show Sample Output


    3
    bash -x SCRIPT
    jcalvert · 2009-03-13 00:09:07 3

What Others Think

Thanks for tip for a debug mode :)
b2e · 467 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: