FG
šŸ’» Software

Linux: How do I execute a script in a way that it knows its directory?

Fresh7 days ago
Mar 15, 20261027 views
Confidence Score0%
0%

Problem

I need to write a script, which would be called from any location, but needs to run from the directory it resides in. The script should query its directory at runtime. How can this be achieved? Example: script resides in though it is called from , the script knows (during runtime) that it resides i…

Error Output

hello.sh

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Linux: How do I execute a script in a way that it knows its directory?

Low Risk

or

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment