RWARRAY(3am)
πΎ rwarray β the gawk manual page, but make it cute πΎ
okay so bestie, this is the rwarray page from the GNU Awk Extension Modules (that's the 3am manual section, awk modules, iykyk). it's about yeeting gawk arrays into files and pulling them back out again. let's GO π
β¨ NAME β¨
writea, reada, writeall, readall β write and read gawk arrays to/from files π
like. the whole vibe is: your array goes in a file, your array comes out a file. no cap.
πΈ SYNOPSIS πΈ
@load "rwarray"
ret = writea(file, array)
ret = reada(file, array)
ret = writeall(file)
ret = readall(file)
that's it that's the whole interface. four little functions. iconic. π
π¦ DESCRIPTION π¦
so the rwarray extension adds four functions, and their names are literally writea(), reada(), writeall(), and readall(). here's the tea on each one β
π
writea()
takes a string argument β that's the name of the file you're dumping the array into β and then the array itself as the second argument. and babes, writea() understands multidimensional arrays. she's not scared of nesting. she's got range. π₯
returns one on success, or zero upon failure. that's it.
π
reada()
this is the inverse of writea(), bestie. she reads the file named as her first argument and fills in the array named as her second argument.
β οΈ heads up: she clears the array first. so whatever was in there before? gone. poof. she's a clean-slate queen.
return value here is also one on success and zero upon failure. consistent. we love consistency.
π
writeall()
takes a string argument β the name of the file where you're dumping the state of all the variables. and get this: calling this function is completely equivalent to calling writea() with the second argument equal to SYMTAB. literally the same thing, just shorter to type. β¨
returns one on success, or zero upon failure.
π
readall()
takes a string argument β the name of the file you're reading the contents of various global variables from. for each variable in the file, the data is loaded unless the variable already exists. and if the variable already exists? the data for that variable in the file is ignored. like, she said "you already got one, i'm not touching that." π
returns one on success, or zero upon failure.
π NOTES π
okay this part is important so listen up π«Ά
the array created by reada() is identical to the one written by writea() β in the sense that the contents are the same. same data, same everything, vibe matched. π―
however. due to implementation issues, the array traversal order of the recreated array will likely be different from that of the original array. π
and like β as array traversal order in AWK is by default undefined, this is not (technically) a problem. technically. so don't come for her.
but if you need to guarantee a particular traversal order? use the array sorting features in gawk to do so. that's the move. β
π§ also: the file contains binary data. all integral values are written in network byte order. however, double precision floating-point values are written as native binary data.
so theoretically, arrays containing only string data can be dumped on systems with one byte order and restored on systems with a different one. but this has not been tried. 𫣠so like⦠good luck with that one, bestie. we believe in you but also we've never tested it.
π EXAMPLE π
here's the whole flow, start to finish, slay:
@load "rwarray"
...
ret = writea("arraydump.bin", array)
...
ret = reada("arraydump.bin", array)
...
ret = writeall("globalstate.bin")
...
ret = readall("globalstate.bin")
see how clean that is?? dump it, read it back, dump the whole global state, read the whole global state back. main character energy fr fr. π
π SEE ALSO π
GAWK: Effective AWK Programmingβ the book, read it, it's giving textbook but make it good- and the man pages for the other extensions shipped with gawk πΈ
π«Ά AUTHOR π«Ά
Arnold Robbins, arnold@skeeve.com.
thank you arnold, we appreciate you, no cap. π
π COPYING PERMISSIONS π
Copyright Β© 2012, 2013, 2018, 2022, 2026, 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. π
and that's the whole page, bestie!! π this one came from the Free Software Foundation and it's dated Feb 25 2026 β so it's fresh, it's current, it's literally timestamped for the future. go dump some arrays. you got this. π β¨π¦
π¦ where this page comes from
- arch rolling: gawk 5.4.1-1 Β· GPL-3.0-or-later
- nixos 26.05: gawk-interactive 5.4.1
- nixpkgs unstable: gawk 5.4.1
- nixpkgs unstable: gawk-interactive 5.4.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms