From owner-freebsd-questions Mon Nov 12 22:37:11 2001 Delivered-To: freebsd-questions@freebsd.org Received: from post.mail.nl.demon.net (post-10.mail.nl.demon.net [194.159.73.20]) by hub.freebsd.org (Postfix) with ESMTP id D756437B405 for ; Mon, 12 Nov 2001 22:37:04 -0800 (PST) Received: from [212.238.77.116] (helo=buffy.raggedclown.net) by post.mail.nl.demon.net with esmtp (Exim 3.33 #1) id 163XBv-0000oM-00 for freebsd-questions@FreeBSD.ORG; Tue, 13 Nov 2001 06:37:03 +0000 Received: by tanya.raggedclown.net (Postfix on SuSE Linux 7.3 (i386), from userid 500) id 0A5C510EE; Tue, 13 Nov 2001 07:36:33 +0100 (CET) Date: Tue, 13 Nov 2001 07:36:32 +0100 From: Cliff Sarginson To: freebsd-questions@FreeBSD.ORG Subject: Re: Got 2 Question Message-ID: <20011113073632.A1516@raggedclown.net> References: <003201c16c16$dbc844e0$d9c89d18@mtki1.on.home.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <003201c16c16$dbc844e0$d9c89d18@mtki1.on.home.com> User-Agent: Mutt/1.3.22.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Nov 12, 2001 at 11:43:16PM -0800, Haroon Khan wrote: > This question I found in a text. > > topic: Bourne shell > > Write a shell script that displays the first 12 command line arguments, = > > one argument per line > #!/bin/sh # 12 args version 1 # for i in 1 2 3 4 5 6 7 8 9 10 11 12 do echo "$1" shift done #!/bin/sh # 12 args version 2 # for i in 1 2 3 4 5 6 7 8 9 10 11 12 do if [ "$1" != "" ]; then echo $1 shift else echo "Less than 12 arguments given dimmo !" 1>&2 exit 1; fi done [ $# -ne 0 ] && { echo "You gave me more than 12 arguments, that exceeds my design spec." 1>&2; } exit 0 #!/bin/sh # 12 args version 3 # MAXARGS=12 NARGS=0 while [ $# -gt 0 ] do echo $1 shift NARGS=`expr $NARGS + 1` [ $# -eq 0 -o $NARGS -eq $MAXARGS ] && { break; } done etc etc etc > second question > topic unix c shell > > What does the following command do? > > 137% pushed ~/literature > No idea, I avoid the C shell except under extreme pressure... -- Regards Cliff To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message