summaryrefslogtreecommitdiff
path: root/awklib/eg/lib/readfile.awk
blob: 9137b26d42af3bc22d9d944efba7911554f288e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# readfile.awk --- read an entire file at once
#
# Original idea by Denis Shirokov, cosmogen@gmail.com, April 2013
#

function readfile(file,     tmp, save_rs)
{
    save_rs = RS
    RS = "^$"
    getline tmp < file
    close(file)
    RS = save_rs

    return tmp
}