github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/docs/job-specification/hcl2/functions/file/fileexists.mdx (about) 1 --- 2 layout: docs 3 page_title: fileexists - Functions - Configuration Language 4 sidebar_title: fileexists 5 description: The fileexists function determines whether a file exists at a given path. 6 --- 7 8 # `fileexists` Function 9 10 `fileexists` determines whether a file exists at a given path. 11 12 ```hcl 13 fileexists(path) 14 ``` 15 16 Functions are evaluated by the CLI during configuration parsing rather than job run time, 17 so this function can only be used with files that are already present on disk on operator host. 18 19 This function works only with regular files. If used with a directory, FIFO, 20 or other special mode, it will return an error. 21 22 ## Examples 23 24 ```shell-session 25 > fileexists("./hello.txt") 26 true 27 ``` 28 29 ```hcl 30 fileexists("custom-section.sh") ? file("custom-section.sh") : local.default_content 31 ``` 32 33 ## Related Functions 34 35 - [`file`](/docs/job-specification/hcl2/functions/file/file) reads the contents of a file at a given path