From owner-freebsd-questions@FreeBSD.ORG Wed Jan 12 22:50:07 2005 Return-Path: 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 CBE5C16A4CE for ; Wed, 12 Jan 2005 22:50:07 +0000 (GMT) Received: from wonkity.com (wonkity.com [67.158.26.137]) by mx1.FreeBSD.org (Postfix) with ESMTP id 66B6F43D46 for ; Wed, 12 Jan 2005 22:50:07 +0000 (GMT) (envelope-from wblock@wonkity.com) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.13.1/8.13.1) with ESMTP id j0CMo69s073055; Wed, 12 Jan 2005 15:50:06 -0700 (MST) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.13.1/8.13.1/Submit) with ESMTP id j0CMo6t8073052; Wed, 12 Jan 2005 15:50:06 -0700 (MST) (envelope-from wblock@wonkity.com) Date: Wed, 12 Jan 2005 15:50:06 -0700 (MST) From: Warren Block To: Toomas Aas In-Reply-To: <41E58A4E.9000105@raad.tartu.ee> Message-ID: <20050112152242.M95286@wonkity.com> References: <41E58A4E.9000105@raad.tartu.ee> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.6 (wonkity.com [127.0.0.1]); Wed, 12 Jan 2005 15:50:06 -0700 (MST) cc: questions@freebsd.org Subject: Re: can't figure out an one-liner X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2005 22:50:07 -0000 On Wed, 12 Jan 2005, Toomas Aas wrote: > # for luser in 'joe peter bill' { tar cf - -C /home $luser | tar xf - } > > ... but I keep getting error messages that luser is undefined. > > What am I doing wrong? In csh, it's "foreach", like this (tested): foreach luser (joe peter bill) echo $luser end The csh man page says: "Both foreach and end must appear alone on separate lines." But you should not use csh for scripting[1]. Instead, stick to standard sh (tested): for luser in joe bill ted; do echo $luser; done But that's ugly. Unless there's a good reason to stick with shell scripts, consider using Perl or Python[2] from the start. [1] Google for it. [2] I'd lean towards Python currently. Shame about the string interpolation, though. -Warren Block * Rapid City, South Dakota USA