# info > readfile

---
type: CommandReference
command: readfile
mode: man
section: 3am
source: man-pages
---

## Quick Reference

- `@load "readfile"` — load the readfile extension
- `result = readfile("/some/path")` — read entire file into a string
- `PROCINFO["readfile"] = 1` — make each input file be returned as a single record

## Name

readfile — return the entire contents of a file as a string

## Synopsis

awk
@load "readfile"
result = readfile("/some/path")
For making whole files be single records:

awk
@load "readfile"
BEGIN { PROCINFO["readfile"] = 1 }
## Examples

awk
@load "readfile"
...
contents = readfile("/path/to/file");
if (contents == "" && ERRNO != "") {
    print("problem reading file", ERRNO) > "/dev/stderr"
}
## See Also

- [filefuncs(3am)](http://localhost/phpMan.php/man/filefuncs/3am/markdown)
- [fnmatch(3am)](http://localhost/phpMan.php/man/fnmatch/3am/markdown)
- [fork(3am)](http://localhost/phpMan.php/man/fork/3am/markdown)
- [inplace(3am)](http://localhost/phpMan.php/man/inplace/3am/markdown)
- [ordchr(3am)](http://localhost/phpMan.php/man/ordchr/3am/markdown)
- [readdir(3am)](http://localhost/phpMan.php/man/readdir/3am/markdown)
- [revoutput(3am)](http://localhost/phpMan.php/man/revoutput/3am/markdown)
- [rwarray(3am)](http://localhost/phpMan.php/man/rwarray/3am/markdown)
- [time(3am)](http://localhost/phpMan.php/man/time/3am/markdown)