Difference between revisions of "Dirname"

From wikieduonline
Jump to navigation Jump to search
Line 15: Line 15:
 
* <code>[[mkdir -p]] "$(dirname "$1")" && [[touch]] "$1"</code>
 
* <code>[[mkdir -p]] "$(dirname "$1")" && [[touch]] "$1"</code>
 
* <code>[[BASH_SOURCE]]</code>
 
* <code>[[BASH_SOURCE]]</code>
 +
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
  
 
== See also ==
 
== See also ==

Revision as of 17:14, 15 August 2022

dirname command included in coreutils package.

cd -- "$(dirname "$0")"
dirname -- "$0";
dirname -- "$( readlink -f -- "$0"; )";

Related terms

script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)

See also

Advertising: