From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18016 invoked by alias); 31 Oct 2012 19:16:04 -0000 Received: (qmail 17988 invoked by uid 22791); 31 Oct 2012 19:16:01 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from plane.gmane.org (HELO plane.gmane.org) (80.91.229.3) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 31 Oct 2012 19:15:50 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TTdld-0002iw-AZ for cygwin@cygwin.com; Wed, 31 Oct 2012 20:15:57 +0100 Received: from 5520-maca-inet1-outside.broadcom.com ([216.31.211.11]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 31 Oct 2012 20:15:57 +0100 Received: from Andrew by 5520-maca-inet1-outside.broadcom.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 31 Oct 2012 20:15:57 +0100 To: cygwin@cygwin.com From: Andrew DeFaria Subject: Re: Command line arguments Date: Wed, 31 Oct 2012 19:16:00 -0000 Message-ID: References: <1351606847888-94081.post@n5.nabble.com> <20121031182143.M67652@ds.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 In-Reply-To: <20121031182143.M67652@ds.net> X-IsSubscribed: yes Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2012-10/txt/msg00485.txt.bz2 On 10/31/2012 11:23 AM, Brian Wilson wrote: > If you have a script (e.g. foo.sh) and you wish to pass arguments to the > script, your command line should look like "foo.sh arg1 arg2 arg3..." The > number of arguments will be correct and you will be able to access them as > ${1}, ${2}, etc. Also, you may want to read up on the getopts command as a > way to process command line arguments. Technically, the {}'s are not needed. You can access them with $1, $2, etc. Most special characters sever as delimiters too so you can refer to them as "This the $1 parameter" or even "/path/to/$1/dir". But if you wanted to do something like this - "This is the ${1}parameter" or even "/path/to/$1.save/dir" but not "/path/to/$1save/dir" you'd need the {} (i.e. "/path/to/${1}save/dir" because otherwise the shell would be looking for "1save" as an env variable name. -- Andrew DeFaria Fear has its use but cowardice has none. - Mohandas Gandhi -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple