Difference between revisions of "Dirname"
Jump to navigation
Jump to search
↑ https://man7.org/linux/man-pages/man1/dirname.1.html
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{lowercase}} | {{lowercase}} | ||
− | <code>dirname</code> | + | <code>dirname</code> <ref> https://man7.org/linux/man-pages/man1/dirname.1.html</ref> command included in <code>[[coreutils]]</code> package. |
− | |||
[[cd]] -- "$(dirname "$0")" | [[cd]] -- "$(dirname "$0")" | ||
+ | |||
+ | dirname -- "$0"; | ||
+ | |||
+ | dirname -- "$( [[readlink]] -f -- "$0"; )"; | ||
== Related terms == | == Related terms == | ||
+ | * <code>[[basename]]</code> | ||
* <code>[[PATH]]</code> [[environment variable]] | * <code>[[PATH]]</code> [[environment variable]] | ||
* <code>[[mkdir -p]]</code> | * <code>[[mkdir -p]]</code> | ||
* <code>[[mkdir -p]] "$(dirname "$1")" && [[touch]] "$1"</code> | * <code>[[mkdir -p]] "$(dirname "$1")" && [[touch]] "$1"</code> | ||
+ | * <code>[[BASH_SOURCE]]</code> | ||
+ | * <code>script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)</code> | ||
== See also == | == See also == |
Latest revision as of 10:12, 28 March 2024
dirname
[1] command included in coreutils
package.
cd -- "$(dirname "$0")"
dirname -- "$0";
dirname -- "$( readlink -f -- "$0"; )";
Related terms[edit]
basename
PATH
environment variablemkdir -p
mkdir -p "$(dirname "$1")" && touch "$1"
BASH_SOURCE
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
See also[edit]
- Coreutils,
tail
,dirname
,env
,sleep
,install, truncate
Bash [ -c ]
,alias
,&&
, Bash history, Autocompletion,set
,unset
,export
,.bash_aliases, .bashrc and .bash profile
,PS1
,echo
,brace expansion
, Function,shopt
,trap
,set -e
,source
,PATH
,complete
,disown
,.hushlogin
,.bashrc
,builtin
,eval
,set
,$PATH
,$HOME
,TZ
,.profile
,-e, -i
,Builtin (Bash)
,mapfile
,~
, return (Bash), for, until,declare, dirname, basename, functions.sh
, Bash arithmetic expansion,shift, bash --rcfile, readonly, $1, $@
Advertising: