|
Home > Archive > Unix questions > January 2006 > Whence Command
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| amerar@iwc.net 2006-01-24, 6:23 pm |
|
Hi All,
I see this command at the top of a script in our
establishment......what is the $0 represent??
myfile=`whence $0`
Thanks
| |
| Steve Foley 2006-01-24, 6:23 pm |
| $0 is the command used to invoke the script.
If the same script is linked to foo and foobar, this will tell you which one
you picked.
<amerar@iwc.net> wrote in message
news:1138119068.159497.232760@g44g2000cwa.googlegroups.com...
>
> Hi All,
>
> I see this command at the top of a script in our
> establishment......what is the $0 represent??
>
> myfile=`whence $0`
>
> Thanks
>
| |
| amerar@iwc.net 2006-01-24, 6:23 pm |
|
So, what do these lines prove???
myfile=`whence $0`
mypath=`dirname $myfile`
| |
| Steve Foley 2006-01-24, 6:23 pm |
| what does the whence command do?
<amerar@iwc.net> wrote in message
news:1138120422.459703.212860@g49g2000cwa.googlegroups.com...
>
> So, what do these lines prove???
>
> myfile=`whence $0`
> mypath=`dirname $myfile`
>
| |
| Bill Marcum 2006-01-24, 8:56 pm |
| On Tue, 24 Jan 2006 16:58:51 GMT, Steve Foley
<steve.foley@DELETE.att.net> wrote:
> what does the whence command do?
>
What does the man command do?
Whence may be a builtin command. Try "type whence" and, if it is
builtin, read the man page for your shell.
--
.... Logically incoherent, semantically incomprehensible, and legally ...
impeccable!
| |
| Steve Foley 2006-01-25, 2:58 am |
| I've got a DG/UX system, and a Linux/Mandrake 10.1. Neither has a whence
command or builtin.
"Bill Marcum" <bmarcum@iglou.com> wrote in message
news:s9sia3-1uu.ln1@don.localnet...
> On Tue, 24 Jan 2006 16:58:51 GMT, Steve Foley
> <steve.foley@DELETE.att.net> wrote:
> What does the man command do?
> Whence may be a builtin command. Try "type whence" and, if it is
> builtin, read the man page for your shell.
>
>
> --
> ... Logically incoherent, semantically incomprehensible, and legally ...
> impeccable!
| |
| Aawara Chowdhury 2006-01-25, 2:58 am |
| In <fhCBf.292825$qk4.4577@bgtnsc05-news.ops.worldnet.att.net>,
Steve Foley <steve.foley@DELETEatt.net> wrote:
> I've got a DG/UX system, and a Linux/Mandrake 10.1. Neither has a whence
> command or builtin.
>
Use the Korn shell on either, and you'll have a whence command (its a ksh
builtin).
AC
--
In America, through pressure of conformity, there is freedom of choice,
but nothing to choose from - Peter Ustinov.
| |
| Stephane CHAZELAS 2006-01-25, 2:58 am |
| 2006-01-25, 03:30(+00), Steve Foley:
> I've got a DG/UX system, and a Linux/Mandrake 10.1. Neither has a whence
> command or builtin.
[...]
It's a builtin in ksh and zsh, and does the same job as "type" but
with many options and a different syntax.
See the useful "whence -m <pattern>" in zsh to search for
commands with a pattern.
$ whence -apm '?sh'
/bin/ash
/usr/bin/ssh
/usr/bin/bsh
/usr/bin/ksh
/usr/bin/zsh
/bin/csh
/usr/bin/rsh
In zsh, "type" is "whence -v", "where" is "whence -ca", "which"
is "whence -c".
--
Stéphane
| |
| Steve Foley 2006-01-29, 9:31 pm |
| myfile is would be the fully qualified name of your script.
mypath is the fully qualified name of the directory where your script was
invoked from.
<amerar@iwc.net> wrote in message
news:1138120422.459703.212860@g49g2000cwa.googlegroups.com...
>
> So, what do these lines prove???
>
> myfile=`whence $0`
> mypath=`dirname $myfile`
>
|
|
|
|
|