Finding the last arg
Rouben Rostamian
rouben at math9.math.umbc.edu
Thu Dec 27 05:50:19 AEST 1990
In article <18476 at shlump.nac.dec.com> lan_csse at 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 at umbc
Baltimore, MD 21228, U.S.A. internet: rostamian at umbc3.umbc.edu
More information about the Comp.unix.shell
mailing list