Skip to main content
can -> do.
Link
Mateen Ulhaq
  • 26.5k
  • 20
  • 115
  • 146

How cando I get the directory where a Bash script is located from within the script itself?

I removed the word 'source'. It does not really fit and it creates false hits for 'source scripts' which is a different thing.
Link
mit
  • 11.2k
  • 11
  • 51
  • 74

How can I get the source directory ofwhere a Bash script is located from within the script itself?

Fixed the question formation - missing auxiliary (or helping) verb - see e.g. <https://www.youtube.com/watch?v=t4yWEt0OSpg&t=1m49s> (see also <https://www.youtube.com/watch?v=kS5NfSzXfrI> (QUASM)) - alternatively, drop the question mark.
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 109
  • 132

How tocan I get the source directory of a Bash script from within the script itself?

How tocan I get the source directory of a Bash script from within the script itself?

How do I get the path of the directory in which a Bash script is located, inside that script?

I want to use a Bash script as a launcher for another application. I want to change the working directory to the one where the Bash script is located, so I can operate on the files in that directory, like so:

$ ./application

How to get the source directory of a Bash script from within the script itself?

How do I get the path of the directory in which a Bash script is located, inside that script?

I want to use a Bash script as a launcher for another application. I want to change the working directory to the one where the Bash script is located, so I can operate on the files in that directory, like so:

$ ./application

How can I get the source directory of a Bash script from within the script itself?

How do I get the path of the directory in which a Bash script is located, inside that script?

I want to use a Bash script as a launcher for another application. I want to change the working directory to the one where the Bash script is located, so I can operate on the files in that directory, like so:

$ ./application
Added "?" at the question-end.
Link
Milan
  • 1.9k
  • 3
  • 15
  • 43
Loading
edited for readability
Source Link
the Tin Man
  • 160k
  • 44
  • 218
  • 306
Loading
Not sure why the title trailed off . . .
Link
Jon Ericson
  • 21.3k
  • 12
  • 99
  • 149
Loading
Changed the title to match the requirement
Source Link
codeforester
  • 41.7k
  • 19
  • 115
  • 149
Loading
Minor title updates
Link
Steve Chambers
  • 38.7k
  • 28
  • 168
  • 217
Loading
Rollback to Revision 7
Source Link
Jiaaro
  • 76k
  • 43
  • 172
  • 191
Loading
clarified the meaning
Source Link
alexyorke
  • 4.3k
  • 3
  • 35
  • 56
Loading
Copy edited.
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 109
  • 132
Loading
Question Protected by NullPoiиteя
added missing question mark.
Source Link
nsheff
  • 3.2k
  • 2
  • 25
  • 31
Loading
We already have [argv], we don't need [argv0]. Manually burninating.
Link
Charles
  • 51.3k
  • 13
  • 105
  • 143
Loading
deleted 2 characters in body; edited tags
Source Link
SamB
  • 9.1k
  • 5
  • 50
  • 56
Loading
clarify that directory is the script, not pwd
Link
idbrii
  • 11.6k
  • 5
  • 70
  • 114
Loading
Post Made Community Wiki
Source Link
Jiaaro
  • 76k
  • 43
  • 172
  • 191
Loading