basename¶
Collection Note
This module is part of the ansible.builtin collection. To install the collection, use:
Added in versionhistorical.
Synopsis¶
- Returns the last name component of a path, what is left in the string that is not 'dirname'.
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| _input path required |
A path. |
Notes¶
Note
- The result of this filter is different from the Unix basename program; where basename for C(/foo/bar/) returns C(bar), the basename filter returns an empty string (C('')).
Examples¶
# To get the last name of a file path, like 'foo.txt' out of '/etc/asdf/foo.txt'.
{{ mypath | basename }}
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| _value | str | The base name from the path provided. |
Authors¶
- Ansible Core Team