[Techtalk] shell scripting

Maria Blackmore mariab at cats.meow.at
Tue Feb 11 01:59:17 EST 2003


On Mon, 10 Feb 2003, Emma Jane Hogbin wrote:

> I added a ; at the end of each line and this seems to have fixed the
> problem. Thanks. :)

cool

> Can you put && at the end of the line and have it do the same thing, or
> does it need to be all on the same line to work its magic? 

Assuming the use of bash, and that you're running a shell script (ie
starts with #!/bin/bash) then it doesn't need to all be on the same line

eg

#!/bin/bash
ls foo&&
echo foo
ls bar&&
echo bar
echo baz

> > If you run one of the commands on a command line, by itself, do you get a
> > shell prompt back straight away?
> 
> No. I have to wait for it to finish to get my prompt back unless I force
> it into the background with a single &.

ok, good, that's what is supposed to happen :)

you may also like to know that the exit code from the last command run
usually ends up in $?.  eg:

	mariab at tigger:~$ echo $?
	0
	mariab at tigger:~$ ls foo
	ls: foo: No such file or directory
	mariab at tigger:~$ echo $?
	1

You will probably find this useful if you're shell scripting :)

Maria




More information about the Techtalk mailing list