Re: bash scripts: how to determine directory of 'source'd file
- From: michael <linux@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 21:26:21 +0000
On Tue, 2006-01-31 at 10:16 -0500, Juergen Fiedler wrote:
> On Tue, Jan 31, 2006 at 02:26:27PM +0000, michael wrote:
> > Presuming I have a file setEnvVars.sh that I wish to source,
> > . path/setEnvVars.sh
> > How do I, within the script, determine the actual directory within which
> > the setEnvVars.sh file sits? The sourcing seems to disallow me access to
> > $0 etc
> >
> > thanks, M
>
> If I understand your question correctly, the '$_' variable should do
> the trick.
doesn't seem to:
michael@ratty:~/models-3/CMAQ-4.5/scripts$ head ../defineEnvVars
#!/bin/bash
echo $_
michael@ratty:~/models-3/CMAQ-4.5/scripts$ . ../defineEnvVars
../defineEnvVars
michael@ratty:~/models-3/CMAQ-4.5/scripts$ cd cctm
michael@ratty:~/models-3/CMAQ-4.5/scripts/cctm$ . ../../defineEnvVars
cctm
what I am trying to do in the script is get it to work out the directory
in which defineEnvVars live, irrespective of which directory I am when I
run
. [path]/defineEnvVars
thanks, michael
--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx
- Follow-Ups:
- Re: bash scripts: how to determine directory of 'source'd file
- From: Randy Belk
- Re: bash scripts: how to determine directory of 'source'd file
- From: Jan C. Nordholz
- Re: bash scripts: how to determine directory of 'source'd file
- References:
- bash scripts: how to determine directory of 'source'd file
- From: michael
- Re: bash scripts: how to determine directory of 'source'd file
- From: Juergen Fiedler
- bash scripts: how to determine directory of 'source'd file
- Prev by Date: Re: /var becomes read-only every day
- Next by Date: Re: [linux-audio-user] RE: 2.6.15 alsa problem
- Previous by thread: Re: bash scripts: how to determine directory of 'source'd file
- Next by thread: Re: bash scripts: how to determine directory of 'source'd file
- Index(es):
Relevant Pages
- RE: forwarding logs
... Same with another script. ... >> You should not need to cange anything
in the log script itself. ... >> Reuben D. Budiardja ... (RedHat) - RE: forwarding logs
... Same with another script. ... >> You should not need to cange anything
in the log script itself. ... >> Reuben D. Budiardja ... (RedHat) - brute force ssh login attempts and how to Disrupt them
... My head ... and I heard a rhythmic tick-tock coming from ... back,
the idiot was gone so apparently, the script gives up ... To UNSUBSCRIBE, email
to debian-user-REQUEST@xxxxxxxxxxxxxxxx ... (Debian-User) - Re: CD to acc
... I m learning python, so thought i should write small py script to ... os.system
(cmd) ... Run this script, while you are in the mounted CD ROM dir... ...
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe".
... (Debian-User) - RE: export question
... environment, but that is what export is supposed to do. ... 'set' command.
... It *is* set in the sub-process created when you run the script. ... To UNSUBSCRIBE,
email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ... (Debian-User)