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