Close Menu
    What's Hot

    YouTube Unblocked Proxy: Overview, Benefits, and Real-World Use Cases

    April 7, 2026

    Linux Kernel Release Frequency Statistics 2026

    April 7, 2026

    How To Use The SSH Login Command

    April 7, 2026
    Facebook X (Twitter) Instagram
    Command Linux
    • About
    • Man Pages
    • Arch Linux
    • Statistics
    • How to
      • Q&A
    • OS
      • Windows
    • Blog
      • Featured
    • MORE
      • Easter Eggs
      • IP Address
    • Write For Us
    • Contact Us
    Command Linux
    Home - man page - READFILE

    READFILE

    WillieBy WillieJanuary 26, 2026Updated:January 26, 2026No Comments2 Mins Read

    NAME

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

    SYNOPSIS

    @load "readfile"

    result = readfile("/some/path")

    For making whole files be single records:

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

    DESCRIPTION

    The readfile extension adds a single function named readfile(). The argument is the name of the file to read. The return value is a string containing the entire contents of the requested file.

    Upon error, the function returns the empty string and sets ERRNO.

    In addition, it adds an input parser that is activated if PROCINFO["readfile"] exists. When activated, each input file is returned in its entirety as $0. RT is set to the null string. # .SH NOTES # .SH BUGS  

    EXAMPLE

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

    AUTHOR

    Arnold Robbins, [email protected].  

    COPYING PERMISSIONS

    Copyright © 2012, 2013, 2014, Free Software Foundation, Inc.

    Permission is granted to make and distribute verbatim copies of this manual page provided the copyright notice and this permission notice are preserved on all copies.

    Permission is granted to copy and distribute modified versions of this manual page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

    Permission is granted to copy and distribute translations of this manual page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation.

    Willie
    • Website

    Willie has over 15 years of experience in Linux system administration and DevOps. After managing infrastructure for startups and enterprises alike, he founded Command Linux to share the practical knowledge he wished he had when starting out. He oversees content strategy and contributes guides on server management, automation, and security.

    Related Posts

    E2FREEFRAG

    April 7, 2026

    Net::DNS::RR::DHCID

    April 7, 2026

    LOGROTATE

    April 7, 2026

    EVP_MD_CTX_destroy

    April 7, 2026
    Top Posts

    TSORT

    February 3, 2026

    IP

    March 9, 2026

    All Linux List Mounts Commands

    March 5, 2026

    Growth Navigate Funding And Capital Prep And Scaling in 2026

    March 3, 2026
    • Home
    • Contact Us
    • Privacy Policy
    • Terms of Use

    Type above and press Enter to search. Press Esc to cancel.