KSH script arguments
Rob McMahon
cudcv at warwick.ac.uk
Fri Aug 31 21:17:42 AEST 1990
In article <1992 at hsi86.hsi.UUCP> kenney at hsi.com (Brian Kenney) writes:
>In article <b4CC02oVc3Jx01 at amdahl.uts.amdahl.com> jonc at amdahl.uts.amdahl.com (Jonathan Chang) writes:
>
>>How can I extract the last argument to a ksh script?
>>Example:
>> myscript arg1 arg2 arg3
>
>args=$*
>arg3=${args##* }
>
>You're welcome.
Of course this breaks horribly if the last argument contains a space.
(Actually it doesn't work at all with bash, you need to escape the ` ' with a
`\', is this a bug ?)
This is one of my pet peeves. People create files with spaces in their names
(often from packages), and I like to be able to tell them "Don't panic, just
surround the names with ''", I don't want to have to say "If you're using x or
y you can use '', but you can't use this with z because it's a shell script,
although of course it does work with w because it's a csh script." People
shouldn't have to know how things are implemented. (Yes, yes, I know, I
should say "just don't create files with spaces in the name :-(, but that
doesn't work for messages, the title of printer jobs, etc.)
Rob
--
UUCP: ...!mcsun!ukc!warwick!cudcv PHONE: +44 203 523037
JANET: cudcv at uk.ac.warwick INET: cudcv at warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England
More information about the Comp.unix.questions
mailing list