Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] displaying executed commands in shell scripts



On Fri, Jun 08, 2007 at 03:09:16PM +0900, Hector Akamine wrote:
> Dave, Chris, Erin,
> Thanks for your help
> 
> On 6/8/07, Erin D. Hughes <erin-hughes@example.com> wrote:
> >
> >Maybe try this.
> >
> ><poor attempt at code>
> >#!/bin/bash
> >echo ls
> >ls
> >exit
> ></poor attempt at  code>
> 
> I was doing something like this, but got tired after doing the same
> thing for a script with more than 3 lines (I'm lazy :-))

do it fancy:

-- 8< --
#!/bin/sh

magenta='\e[0;35m'
clear='\e[0m'

ecmd() {
	echo -e "# ${magenta}$@example.com"
	$@
}

ecmd ls
ecmd ps ax -T
ecmd echo "I'm the script $0"
-- 8< --

> Dave's tip (adding set -x and set +x in the part of the script I want
> the commands to be shown) did the trick. arigato!

sorry for the useless comment :)
-- 
mattia
:wq!


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links