Set cwd to script directory
Published on 22 January 2020 at 22:53 by
Perhaps this will be the smallest snippet I've ever posted, and yet, one of the most useful. If you have a script that you want to be able to invoke from anywhere and yet not worry about relative paths, use this.
cd "${0%/*}"
This works great when you have a script in a subdirectory that builds a dockerfile, and you want it to look for the relative Dockerfile.