I want to run a shell script that copies a file. I don't like to make absolute reference to that file.
myproject/target/myapp.jar
myproject/docs/copy.sh
copy.sh contains:
scp ~/Projects/myproject/target/myapp.jar user@myip:/var/www
Question: how can I run the copy.sh
shell script and reference the myapp.jar
relative? Like first walking up one folder, and then going into /target
?
From
myproject/docs/copy.sh
you want 2 directories up and into target. You can do that with ...This though ...
I would use a variable and set it at the beginning of your script or from a configuration. You can't use ../../ inside the
scp
when you have "Projects" above it.This will give you the directory your script is in: