$ ls -l
bin/
$ ls bin/
startup.sh shutdown.sh
I wrote a script named restart.sh
inside the bin/
looks like
#!/bin/sh
sh ./shutdown.sh
sh ./startup.sh
Now the bin/
directory looks like this.
$ ls -l bin/
startup.sh shutdown.sh restart.sh
When I execute the restart.sh
inside the bin/
it works.
When I execute the restart.sh
outside the bin/
it doesn't.
$ ls
bin/
$ ./bin/restart.sh
sh: ./shutdown.sh: No such file or directory
sh: ./startup.sh: No such file or directory
$ cd bin
$ ./restart.sh
I'm happy...
How can I make this work?
Why down-votes? Is this normal?
UPDATE
I appreciate both comments and answers. I already know what .
means in system. My apology must be given for making people confused. I accepted the answer because that is what exactly the context to be understood by my question. I should've asked some like How can I make a shell script known to its path..?
I give my answer for someone else. There are plenty of search results for detecting the actual position in shell scripts. I found one at How a BASH script can find its own location.
#!/bin/sh
wd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo $wd
sh $wd/shutdown.sh
sh $wd/startup.sh