Re: bash scripts: how to determine directory of 'source'd file
- From: Randy Belk <randy.belk@xxxxxxxxx>
- Date: Tue, 31 Jan 2006 16:35:39 -0600
michael wrote:
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.shIf I understand your question correctly, the '$_' variable should do
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
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
I think you might want this.
appdirname=`pwd` rcname=backup/include echo $appdirname"/"$rcname
But the following would be better if all the contents of the app are in the same directory...
rcname=`pwd`/backup/include echo $rcname
Hope this helps....
--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx
- 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
- Re: bash scripts: how to determine directory of 'source'd file
- From: michael
- bash scripts: how to determine directory of 'source'd file
- Prev by Date: reiser4 vs reiserfs
- Next by Date: Re: Grub install question?
- Previous by thread: Re: bash scripts: how to determine directory of 'source'd file
- Next by thread: dependency hell dist-upgrade the "right way"
- Index(es):
Relevant Pages
- Re: bash scripts: how to determine directory of sourced file
... > How do I, within the script, determine the actual directory within which ...
The sourcing seems to disallow me access to ... the trick. ... (Debian-User) - Re: IE SCRIPT ERROR
... MS-MVP Windows Shell/User ... Michael W. hunted and pecked: ...
Now after downloading their software I get "Internet Explorer Script ... Display a notification
about every script error ... (microsoft.public.windowsxp.help_and_support) - Re: MS mail bombs
... > Michael C. wrote: ... Someone else mentioned this, I was happy with the
script, I never said ... I've modified it since to check content-type: ...
I read it off usenet using ... (Debian-User) - Re: Projektnummer vor E-Mail Versand eingeben / Pflichteingaben vor Versand
... > Dein Script habe ich im Editor unter "Microsoft Office Outlook Objekt" ...
Michael Bauer - MVP Outlook ... Prev by Date: ... Next by Date: ...
(microsoft.public.de.outlook) - Re: IE SCRIPT ERROR
... MS-MVP Windows Shell/User ... Michael W. hunted and pecked: ...
Now after downloading their software I get "Internet Explorer Script ... Display a notification
about every script error ... (microsoft.public.windowsxp.help_and_support)