- #1
jf22901
- 55
- 1
Hi everyone
I'm having trouble working out how to import a specified path into a bash script. Basically, I have numerous scripts, each of which writes their output to a certain directory via the command
However, in the future this directory may change, so rather than having to manually change the path of the directories in each file, I was wanting to create one file that specifies the path, and then have the other files include it. That way I only have to change one file if the path changes.
Initially I thought of having the path specified in a file such as 'path.sh', which would simply look like
and then I thought that in the other files that require the path I could just put
However, such coding does not work, and I have no idea how to go about fixing it. Could anyone offer any suggestions as to the best way to include a path specified in another file? I'm new to all this bash scripting stuff!
Many thanks
I'm having trouble working out how to import a specified path into a bash script. Basically, I have numerous scripts, each of which writes their output to a certain directory via the command
Code:
set wdir = "/home/..."
However, in the future this directory may change, so rather than having to manually change the path of the directories in each file, I was wanting to create one file that specifies the path, and then have the other files include it. That way I only have to change one file if the path changes.
Initially I thought of having the path specified in a file such as 'path.sh', which would simply look like
Code:
FILEPATH="/home/..."
and then I thought that in the other files that require the path I could just put
Code:
#!/bin/bash
.
.
.
source path.sh
set wdir = $(FILEPATH)
.
.
.
However, such coding does not work, and I have no idea how to go about fixing it. Could anyone offer any suggestions as to the best way to include a path specified in another file? I'm new to all this bash scripting stuff!
Many thanks