github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/hcl2/functions/file/basename.mdx (about) 1 --- 2 layout: docs 3 page_title: basename - Functions - Configuration Language 4 description: |- 5 The basename function removes all except the last portion from a filesystem 6 path. 7 --- 8 9 # `basename` Function 10 11 `basename` takes a string containing a filesystem path and removes all except 12 the last portion from it. 13 14 This function works only with the path string and does not access the 15 filesystem itself. It is therefore unable to take into account filesystem 16 features such as symlinks. 17 18 If the path is empty then the result is `"."`, representing the job file directory. 19 20 The behavior of this function depends on the host platform. On Windows systems, 21 it uses backslash `\` as the path segment separator. On Unix systems, the slash 22 `/` is used. 23 24 Referring directly to filesystem paths in job arguments may cause 25 spurious diffs if the same configuration is applied from multiple systems or on 26 different host operating systems. We recommend using filesystem paths only 27 for transient values, such as the argument to [`file`](/docs/job-specification/hcl2/functions/file/file) (where 28 only the contents are then stored). 29 30 ## Examples 31 32 ```shell-session 33 > basename("foo/bar/baz.txt") 34 baz.txt 35 ``` 36 37 ## Related Functions 38 39 - [`dirname`](/docs/job-specification/hcl2/functions/file/dirname) returns all of the segments of a filesystem path 40 _except_ the last, discarding the portion that would be returned by 41 `basename`.