github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/hcl2/functions/file/file.mdx (about) 1 --- 2 layout: docs 3 page_title: file - Functions - Configuration Language 4 description: |- 5 The file function reads the contents of the file at the given path and 6 returns them as a string. 7 --- 8 9 # `file` Function 10 11 `file` reads the contents of a file at the given path and returns them as 12 a string. 13 14 ```hcl 15 file(path) 16 ``` 17 18 Strings in the Nomad language are sequences of Unicode characters, so 19 this function will interpret the file contents as UTF-8 encoded text and 20 return the resulting Unicode characters. If the file contains invalid UTF-8 21 sequences then this function will produce an error. 22 23 Functions are evaluated by the CLI during configuration parsing rather than job run time, 24 so this function can only be used with files that are already present on disk on operator host. 25 26 ## Examples 27 28 ```shell-session 29 > file("./hello.txt") 30 Hello World 31 ``` 32 33 ## Related Functions 34 35 - [`fileexists`](/docs/job-specification/hcl2/functions/file/fileexists) determines whether a file exists 36 at a given path.