I have several directories, and in each directory there is a shell script, which MUST be started within and from its path.
cd "$(dirname "$0")"
I have several directories, and in each directory there is a shell script, which MUST be started within and from its path.
The structure looks like this:
/directory-one/application_1/my-shell-1.sh /directory-two/application_2/my-shell-2.sh /directory-three/application_3/my-shell-3.sh
Of course, I could mae my master-shell-script so, that I first go into the first one, execute, then cd to the second one, execute and last cd to the third one, execute, but I suppose, there is an easier way.
Is there a reason not to just make these scripts cd to their own
directory so the caller doesn't have to care?
cd "$(dirname "$0")"
On Fri, Sep 06, 2024 at 11:10:16 +0000, Andy Smith wrote:
Is there a reason not to just make these scripts cd to their own
directory so the caller doesn't have to care?
cd "$(dirname "$0")"
https://mywiki.wooledge.org/BashFAQ/028
What I am exactly want to do:
I have 5 live-build directories. In each I am starting my own script, which is
setting variables and so on for the individual build and does some other things (rennamin and copying the resulted ISO and so on).
If bash does not offer this option, I will find another way, but I hope, someone more experienced with shellscripts or bash might have a quick solution. If not, no problem, it does not harm anyone.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 22:48:17 |
Calls: | 10,390 |
Calls today: | 1 |
Files: | 14,063 |
Messages: | 6,416,994 |