newby bash script question

Tyler Aviss tjaviss-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Sat Sep 1 22:54:15 UTC 2007


You can actually do a "cd" within a bash script and it will do the
same as if done manually from the command-line, it's not really that
discriminatory as to who is entering input (script or user) in most
cases.

So in your script, just do
cd B
latex file.tex

The same as you might do from the command-line. Alternately, it might
just be a good idea to hardcode B into a variable or something of the
like:

NEWDIR=/path/to/B
cd ${NEWDIR}
latex file.tex



On 9/1/07, Alex Maynard <maynarda-dxuVLtCph9gsA/PxXw9srA at public.gmane.org> wrote:
>
> Hi All,
>
> I'm sorry to be posting you what should be a very simple
> bash script question. Somehow I haven't quite been able to find an answer to this.
> (Probably I am picking bad search words on google.)
>
> It boils down to not being able to cd properly inside a bash  script.
>
> What I am trying to is to run a script from directory A
> A$./script
> That would have the same effect as using cd to get to directory
> B and then running a file. Specifically, I would like the script to do
> the command line equivalent of:
>
> A$ cd B
> B$ latex file.tex
>
> which is my case produces different results then
> A$ latex B/file.tex
>
> because the first way latex would look for other files (such as style
> files) in directory B where they should be but the second way it
> will look for them in A instead where it won't find them.
>
> Sorry for posting such a basic question and thanks very much for any
> suggestions you might have.
>
> Alex
>
>
>
>
>
> --
> The Toronto Linux Users Group.      Meetings: http://gtalug.org/
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
>
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list