From owner-freebsd-questions Sun Jul 14 13:43:32 2002 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 817D737B400; Sun, 14 Jul 2002 13:43:28 -0700 (PDT) Received: from mail2.hd.intel.com (hdfdns02.hd.intel.com [192.52.58.11]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9E27343E31; Sun, 14 Jul 2002 13:43:27 -0700 (PDT) (envelope-from pavan.balaji@intel.com) Received: from fmsmsxvs041.fm.intel.com (fmsmsxvs041.fm.intel.com [132.233.42.126]) by mail2.hd.intel.com (8.11.6/8.11.6/d: solo.mc,v 1.42 2002/05/23 22:21:11 root Exp $) with SMTP id g6EKhQM25901; Sun, 14 Jul 2002 20:43:26 GMT Received: from FMSMSX017.fm.intel.com ([132.233.42.196]) by fmsmsxvs041.fm.intel.com (NAVGW 2.5.2.11) with SMTP id M2002071413431208878 ; Sun, 14 Jul 2002 13:43:12 -0700 Received: by fmsmsx017.fm.intel.com with Internet Mail Service (5.5.2653.19) id <3DWB2XVW>; Sun, 14 Jul 2002 13:43:25 -0700 Message-ID: <3D386AED1B47D411A94300508B11F18703BC5BA5@fmsmsx116.fm.intel.com> From: "Balaji, Pavan" To: "'Giorgos Keramidas'" , "Balaji, Pavan" Cc: "'freebsd-questions@freebsd.org'" Subject: RE: argc/argv in bash! Date: Sun, 14 Jul 2002 13:43:24 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" 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 Thanx! Pavan Balaji, CIS Graduate Student, Ohio State University "Being happy doesn't mean that everything is perfect... It just means that you have decided to see beyond the imperfections" -- Rash > -----Original Message----- > From: Giorgos Keramidas [mailto:keramida@FreeBSD.org] > Sent: Sunday, July 14, 2002 3:05 PM > To: Balaji, Pavan > Cc: 'freebsd-questions@freebsd.org' > Subject: Re: argc/argv in bash! > > > On 2002-07-14 12:53 +0000, Balaji, Pavan wrote: > > > > How do we use argc and argv (C like) in bash scripts? > > The number of command line arguments is $#. For example: > > % cat foo.sh > #!/bin/sh > echo $# > > % sh foo.sh > 0 > > % sh foo.sh hello world > 2 > > % sh foo.sh "hello world" > 1 > > The argv[] equivalent is $@. > > % cat foo2.sh > #!/bin/sh > > for argument in $@ ;do > echo $argument > done > > % sh foo2.sh > % > > % sh foo2.sh hello world > hello > world > % > > % sh foo2.sh "hello world" > hello world > % > > For more details about the "special variables" of sh, read the sh(1) > manpage. > > % man 1 sh > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message