Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!zaphod.mps.ohio-state.edu!wuarchive!uunet!mcsun!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.unix.questions Subject: Re: $argv[$#argv] Message-ID: <1154@mwtech.UUCP> Date: 27 May 91 23:04:57 GMT References: <1991May25.204543.6428@midway.uchicago.edu> <16278@smoke.brl.mil> Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 23 In article <16278@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: >In article <1991May25.204543.6428@midway.uchicago.edu> goer@ellis.uchicago.edu (Richard L. Goerwitz) writes: >>It's not obvious to me how to take the value of the last argv >>element with /bin/sh, the way one can do with the C-Shell using >>subscripts. Perhaps an ignorant question, but how do? Yes, you're right, it's ignorant - especially ignorant of the FAQ posted monthly to this group (refer to question #32). >It's somewhat context sensitive, but here's one example: > $ set -- a b c > $ echo `eval echo $"$#"` > c But as Doug was already kind enough to post one possible solution, I'll post another (which happens to be my favorite as it works on ALL flavours of the bourne shell and with ANY number of arguments): for last do :; done Now the last argument is left in the shell variable last. -- Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83