How to reference a file relative to the current dir in a shell script?

From myproject/docs/copy.sh you want 2 directories up and into target. You can do that with ...

../../target/myapp.jar

This though ...

scp ~/Projects/myproject/target/myapp.jar user@myip:/var/www

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:

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"