Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Echoing script commands

Status
Not open for further replies.

grega

Programmer
Feb 2, 2000
932
GB
If I have a shell script myscript.sh, and I execute it using myscript.sh > myscript.out 2>&1 all works fine.

Is there a way to tell the shell to echo each command that it executes within that script to the output file also?

e.g if the script contains the commands
Code:
whoami
rm afile
I'd like the script to echo the command to the o/p file as it runs through each one. At the moment I have to do
Code:
echo "whoami"
whoami
echo "rm afile"
rm afile
Greg.
 
I always do this ... you need to do a set -x at the start of the script.

Greg.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top