From owner-freebsd-newbies@FreeBSD.ORG Fri Dec 31 09:36:16 2004 Return-Path: Delivered-To: freebsd-newbies@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B47016A4CE for ; Fri, 31 Dec 2004 09:36:16 +0000 (GMT) Received: from fidel.freesurf.fr (fidel.freesurf.fr [212.43.206.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id C574943D2D for ; Fri, 31 Dec 2004 09:36:15 +0000 (GMT) (envelope-from olivier@gautherot.net) Received: from [192.168.0.2] (62-240-248-216.adsl.freesurf.fr [62.240.248.216]) by fidel.freesurf.fr (Postfix) with ESMTP id 11D0E2A5D14; Fri, 31 Dec 2004 10:36:13 +0100 (CET) Message-ID: <41D51D98.7010006@gautherot.net> Date: Fri, 31 Dec 2004 10:36:24 +0100 From: Olivier Gautherot User-Agent: Mozilla Thunderbird 1.0 (X11/20041215) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Huppi References: <49B5BEF2.7CCF22F4.0F75C5EC@netscape.net> <1104458982.622.3.camel@chaucer> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit cc: vijayendra gadgil cc: freebsd-newbies@freebsd.org Subject: Re: Shell Games X-BeenThere: freebsd-newbies@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Gathering place for new users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Dec 2004 09:36:16 -0000 Hi folks! >>>FWIW, I've always used 'tcsh' interactively, but almost switched a >>>while back out of disgust at not being able to figure out how to >>>get a one-line foreach/{do_something}/end loop (which would allow >>>me to re-run a complex command easily.) >>> >>> >>I would recommend 'ksh' it does the tasks of both 'csh' and 'sh' with >>advanced programming features, check out http://www.kornshell.com/ >> >> > >As it happens, my attempts to do this one-liner with 'tcsh' were a >direct result of watching someone who used 'ksh'. I thought it >probable that 'bash' also could accomplish this feat (and maybe >'tcsh' also if I could figure it out.) Anyone know? > > The keyword is "for", not "foreach". Try: bash-2.05b$ for n in tata tete titi toto tutu ; do echo "New item" ; echo $n ; done New item tata New item tete New item titi New item toto New item tutu bash-2.05b$ Note that the "do" must be followed directly by a command. A semicolon (i.e. an empty command) is considered a syntax error. My cent worth ;-) Olivier