0

Say I have ~/scripts in my $PATH and I have script.sh inside that path.

I can execute that script by typing script.sh directly in the terminal, but what if I want to print out the full path of that script without knowing the base path of the script (or added any function inside the script to print out its own path)? Are there any good ways to do this?

what the
  • 119
  • 6

1 Answers1

1

In bash, to locate a file (script) in the users path, you can use the which command: (https://ss64.com/bash/which.html), but as @Jetchisel says there are better alternatives for POSIX-compliant shells; see 'which' vs 'command -v' in Bash

jared_mamrot
  • 6,036
  • 3
  • 11
  • 30