Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bu.edu!purdue!haven!umbc3!math9.math.umbc.edu!rouben From: rouben@math9.math.umbc.edu (Rouben Rostamian) Newsgroups: comp.unix.shell Subject: Re: Finding the last arg Keywords: Bourne shell arguments Message-ID: <4744@umbc3.UMBC.EDU> Date: 26 Dec 90 18:50:19 GMT References: <18476@shlump.nac.dec.com> Sender: newspost@umbc3.UMBC.EDU Reply-To: rouben@math9.math.umbc.edu.UUCP (Rouben Rostamian) Organization: Mathematics Department University of Maryland, Baltimore County Lines: 22 In article <18476@shlump.nac.dec.com> lan_csse@netrix.nac.dec.com (CSSE LAN Test Account) writes: >What I've been trying to do is write a script whose semantics are sort of >like the cp/mv/ln commands, in that the last argument is special. If it >is a directory, I want to do something different that amounts to appending >character strings to its name to give file name[s] within the directory; >if it is an ordinary file, I just want to use its name. > >The problem is that I can't figure out any Bourne-shell expression that >gives the last argument. In C-shell, it's easy (argv[$#]). But I need >to write Bourne shell scripts. Here's what you need: #!/bin/sh eval lastarg=\${$#} ...etc... -- Rouben Rostamian Telephone: (301) 455-2458 Department of Mathematics and Statistics e-mail: University of Maryland Baltimore County bitnet: rostamian@umbc Baltimore, MD 21228, U.S.A. internet: rostamian@umbc3.umbc.edu