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