github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/website/docs/language/functions/basename.html.md (about)

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