You are not logged in.
I've got a bash script which has many different commands it executes in a row. Each time the script executes one of the commands, it outputs what it is doing to the screen:
...
echo "cp -r home new"
cp -r home new
echo "mv testfile new/."
mv testfile new/.
...
I am just wondering if there is a function to execute a command and output it at the same time. Something like...
...
echoandexecute("cp -r home new")
echoandexecute("mv testfile new/.")
...
Last edited by tony5429 (2008-08-27 19:59:04)
Offline
At the top of your shell script, you presumably have a line like "#!/bin/sh". Change that to "#!/bin/sh -x".
Offline
Thanks! It works now!
Last edited by tony5429 (2008-08-27 19:22:29)
Offline
Otherwise you can define it yourself:
echoandexecute() {
echo $1
$1
}
echoandexecute "cp -r home new"
Last edited by catwell (2008-08-27 20:57:16)
Offline