Re: Shell scripting question [newby]

2006-04-10 Thread Jan Grant
On Mon, 10 Apr 2006, Malcolm Fitzgerald wrote:

> 
> On 10/04/2006, at 12:39 AM, Jan Grant wrote:
> 
> > On Sun, 9 Apr 2006, Malcolm Fitzgerald wrote:
> > 
> > > I'm trying to follow the instructions at
> > > 

> Your advice got me to step 7 where the need to pass a control structure to the
> loop stopped me again.
> 
> I got a bash shell and I write:
> 
> for dist in base dict doc games info manpages ports; do
> cat /mnt/6.0-RELEASE/${dist}/${dist}.?? > /usr/${dist}.tgz
> done
> 
> I put it onto three lines by typing "\" at the end of each line to achieve the
> layout and I get the prompt ">". When I get to the end, ie, "done" I press
> Enter and get another prompt.
> 
> How can I get the multi-line command executed?

What you're doing is roughly this: (note, I supplied a separate "done", 
you'll see why)

[[[
$ for i in one two three; do \
> echo $i \
> done
> done
one done
two done
three done
$
]]]

the first "done" is counted as part of the "echo" argument list.

If you terminate a line with a "\" character, then the intervening 
newline is treated as "just whitespace". Consequently, were you to use 
this syntax, you'd need to punctuate your script properly:

for i in one two three; do \
echo $i; \
done


Having said that, you don't need the "\" marks, because bash (and sh) 
are smart enough to parse as you go and keep prompting until the command 
is complete. Thus you can just type:

for i in one two three; do
echo $i
done

and it'll do what you're asking.

Cheers,
jan


-- 
jan grant, ISYS, University of Bristol. http://www.bris.ac.uk/
Tel +44 (0)117 3317661   http://ioctl.org/jan/
Strive to live every day as though it was last Wednesday.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Shell scripting question [newby]

2006-04-09 Thread Malcolm Fitzgerald


On 10/04/2006, at 12:39 AM, Jan Grant wrote:


On Sun, 9 Apr 2006, Malcolm Fitzgerald wrote:


I'm trying to follow the instructions at


At point four it offers this shell script.

cut -f 1 -d '$' /usr/local/freebsd-update/work/md5all | uniq |
while read X; do
if [ -f $X ]; then echo $X; fi;
done | sort > /root/base-old

Running this from root shell in konsole (bash) I get "while: 
Expression
Syntax". The various hints and clues I get from the shell, the web 
and man
bash haven't helped me. Would someone provide the correct syntax for 
me?


That syntax is correct for sh and bash; you're not running it, however.
Double-check that after you su to root, you're really running bash. 
That

error is what csh will tell you.



Thanks Jan,

Your advice got me to step 7 where the need to pass a control structure 
to the loop stopped me again.


I got a bash shell and I write:

for dist in base dict doc games info manpages ports; do
cat /mnt/6.0-RELEASE/${dist}/${dist}.?? > /usr/${dist}.tgz
done

I put it onto three lines by typing "\" at the end of each line to 
achieve the layout and I get the prompt ">". When I get to the end, ie, 
"done" I press Enter and get another prompt.


How can I get the multi-line command executed?

Malcolm

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Shell scripting question [newby]

2006-04-09 Thread Malcolm Fitzgerald


On 10/04/2006, at 12:39 AM, Jan Grant wrote:


On Sun, 9 Apr 2006, Malcolm Fitzgerald wrote:


I'm trying to follow the instructions at


At point four it offers this shell script.

cut -f 1 -d '$' /usr/local/freebsd-update/work/md5all | uniq |
while read X; do
if [ -f $X ]; then echo $X; fi;
done | sort > /root/base-old

Running this from root shell in konsole (bash) I get "while: 
Expression
Syntax". The various hints and clues I get from the shell, the web 
and man
bash haven't helped me. Would someone provide the correct syntax for 
me?


That syntax is correct for sh and bash; you're not running it, however.
Double-check that after you su to root, you're really running bash. 
That

error is what csh will tell you.


You are right. My user konsole is bash and I presumed that root console 
was too but asking $0 returned su, so I was guessing.


Thanks for the help

malcolm


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Shell scripting question [newby]

2006-04-09 Thread Jan Grant
On Sun, 9 Apr 2006, Malcolm Fitzgerald wrote:

> I'm trying to follow the instructions at
> 
> 
> At point four it offers this shell script.
> 
> cut -f 1 -d '$' /usr/local/freebsd-update/work/md5all | uniq |
> while read X; do
> if [ -f $X ]; then echo $X; fi;
> done | sort > /root/base-old
> 
> Running this from root shell in konsole (bash) I get "while: Expression
> Syntax". The various hints and clues I get from the shell, the web and man
> bash haven't helped me. Would someone provide the correct syntax for me?

That syntax is correct for sh and bash; you're not running it, however. 
Double-check that after you su to root, you're really running bash. That 
error is what csh will tell you.

-- 
jan grant, ISYS, University of Bristol. http://www.bris.ac.uk/
Tel +44 (0)117 3317661   http://ioctl.org/jan/
Whenever I see a dog salivate I get an insatiable urge to ring a bell.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: Shell scripting question [newby]

2006-04-09 Thread Daniel A.
On 4/9/06, Malcolm Fitzgerald <[EMAIL PROTECTED]> wrote:
> I'm trying to follow the instructions at
> 
>
> At point four it offers this shell script.
>
> cut -f 1 -d '$' /usr/local/freebsd-update/work/md5all | uniq |
>  while read X; do
>  if [ -f $X ]; then echo $X; fi;
>  done | sort > /root/base-old
>
> Running this from root shell in konsole (bash) I get "while: Expression
> Syntax". The various hints and clues I get from the shell, the web and
> man bash haven't helped me. Would someone provide the correct syntax
> for me?
>
>
> thanks
>
> malcolm
>
> ___
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "[EMAIL PROTECTED]"
>
Are you sure it shouldnt be "$X" instead of "X" in the while clause?
I dont know, never tried bash scripting before :)
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Shell scripting question [newby]

2006-04-09 Thread Malcolm Fitzgerald
I'm trying to follow the instructions at 



At point four it offers this shell script.

cut -f 1 -d '$' /usr/local/freebsd-update/work/md5all | uniq |
while read X; do
if [ -f $X ]; then echo $X; fi;
done | sort > /root/base-old

Running this from root shell in konsole (bash) I get "while: Expression 
Syntax". The various hints and clues I get from the shell, the web and 
man bash haven't helped me. Would someone provide the correct syntax 
for me?



thanks

malcolm

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"