Date: Tue, 13 Nov 2001 07:36:32 +0100 From: Cliff Sarginson <cliff@raggedclown.net> To: freebsd-questions@FreeBSD.ORG Subject: Re: Got 2 Question Message-ID: <20011113073632.A1516@raggedclown.net> In-Reply-To: <003201c16c16$dbc844e0$d9c89d18@mtki1.on.home.com> References: <003201c16c16$dbc844e0$d9c89d18@mtki1.on.home.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011113073632.A1516>
