From owner-freebsd-questions@FreeBSD.ORG Mon Apr 10 08:56:17 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 29BD416A401 for ; Mon, 10 Apr 2006 08:56:17 +0000 (UTC) (envelope-from jan.grant@bristol.ac.uk) Received: from dirg.bris.ac.uk (dirg.bris.ac.uk [137.222.10.102]) by mx1.FreeBSD.org (Postfix) with ESMTP id AF86843D45 for ; Mon, 10 Apr 2006 08:56:16 +0000 (GMT) (envelope-from jan.grant@bristol.ac.uk) Received: from mail.ilrt.bris.ac.uk ([137.222.16.62]) by dirg.bris.ac.uk with esmtp (Exim 4.60) (envelope-from ) id 1FSsBy-0002TL-8I; Mon, 10 Apr 2006 09:56:16 +0100 Received: from cse-jg.cse.bris.ac.uk ([137.222.12.37]:63451) by mail.ilrt.bris.ac.uk with esmtps (TLSv1:AES256-SHA:256) (Exim 4.50) id 1FSsBt-00011t-3V; Mon, 10 Apr 2006 09:56:13 +0100 Date: Mon, 10 Apr 2006 09:56:08 +0100 (BST) From: Jan Grant X-X-Sender: cmjg@tribble.ilrt.bris.ac.uk To: Malcolm Fitzgerald In-Reply-To: Message-ID: <20060410095005.H15367@tribble.ilrt.bris.ac.uk> References: <20060409153819.V96633@tribble.ilrt.bris.ac.uk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spamassassin: mail.ilrt.bris.ac.uk X-Spam-Score: 0.0 X-Spam-Level: / X-Spam-Score: -1.4 X-Spam-Level: - Cc: freebsd-questions@freebsd.org Subject: Re: Shell scripting question [newby] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Apr 2006 08:56:17 -0000 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.