Question : echo commands in unix shell script

I am working on a very simple script and want it to output the command so I can see what is going on.
Assume I have this very simple script.  I want to see it actually say "export PATH=$PATH:/usr/java/jdk1.6.0_01/bin" in the terminal window as it runs not just the output from the commands.  In DOS I have to expilixtly say echo off to hide this but can't seem to find a way to turn it on in UNIX.

1:
2:
3:
4:
5:
6:
#!/bin/bash
clear
export PATH=$PATH:/usr/java/jdk1.6.0_01/bin
cd /var/glassfish-v2ur1-b09d/domains/domain1/config/
keytool -delete -alias s1as -keystore keystore.jks

Answer : echo commands in unix shell script

Hi,

use "set -x" to have the shell display what it does.

Use "set -xv" to see intermediate steps (e.g. results of variable substitutions) as weel-

Use "set +x" or "set +xv" to turn the setting off again.

#!/bin/bash
clear
set -x  # turn "echo" on
# or
# set -xv
export PATH=$PATH:/usr/java/jdk1.6.0_01/bin
cd /var/glassfish-v2ur1-b09d/domains/domain1/config/
set +x # turn it off
keytool -delete -alias s1as -keystore keystore.jks


wmp
Random Solutions  
 
programming4us programming4us