AllSupported
Home How To Linux Search
  1. Home
  2. /
  3. .sh
  4. /
  5. Get current directory of script file in shell script

Get current directory of script file in shell script

By Tech Writer • December 10, 2014 • 1 min read

  

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

Creds: http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in

AllSupported

Your trusted source for tech support and tutorials.

Categories

  • How To (90)
  • Linux (35)
  • PHP (26)
  • Productivity (23)

Resources

  • About Us
  • Contact
  • RSS Feed

Connect

Stay updated with the latest tech support articles and tutorials.

© 2026 AllSupported. All rights reserved.