INPLACE(3am)
π INPLACE π
ok so bestie, welcome to inplace from the GNU Awk Extension Modules β the little extension that's out here doing sed/perl/ruby in-place editing for gawk. no cap, it's iconic.
β¨ NAME β¨
inplace β emulate sed/perl/ruby in-place editing π
πΈ SYNOPSIS πΈ
gawk -i inplace ...
that's it. that's the whole vibe. π
π¦ DESCRIPTION π¦
okay so here's the tea. the inplace extension adds two functions, and their names are inplace_begin() and inplace_end(). these cuties are meant to be invoked from the inplace.awk wrapper β which, btw, gets installed right alongside gawk itself. they're a package deal. π«Ά
by default, every named file on the command line gets replaced with a brand new file of the exact same name, and the contents of that new file are whatever your AWK program produced. so far so slay. BUT β and this is the part you need to know β since a new file is being created, if the file is a link (whether hard or symbolic), the link will be broken. π not a glitch, that's just how it is. and honestly? this behavior is consistent with GNU sed, which also breaks links when you use the -i or --in-place flag. so if you came from sed, you already know this energy. β¨
now, if the user supplies an AWK variable named inplace::suffix β either in a BEGIN rule or right there on the command line β then the inplace extension concatenates that suffix onto the original filename, and uses the result as the filename for renaming the original. cute, right? π
and for backwards compatibility, the variable will also check INPLACE_SUFFIX (in the awk namespace) for the suffix to use, if inplace::suffix isn't set. so it's got your back either way. π
you can also disable inplace editing selectively, bestie β just place inplace::enable=0 on the command line prior to the files that should be processed normally. and then when you want it back on? place inplace::enable=1 prior to the files that should be subject to inplace editing. boom. toggle acquired. π₯
π BUGS π
ok so, real talk. while the extension does attempt to preserve ownership and permissions, it makes no attempt to copy the ACLs from the original file. so like, if you were counting on thoseβ¦ you weren't. π
and if the program dies prematurely β as might happen if an unhandled signal is received β a temporary file may be left behind. π yeah. it's just gonna be sitting there. unsupervised. so maybe check your directory after a crash, bestie.
π EXAMPLE π
gawk -i inplace 'script' files ...
gawk -i inplace -f scriptfile files ...
look at that. two whole examples. we love a practical queen. π
β SEE ALSO β
GAWK: Effective AWK Programming, and the man pages for the other extensions shipped with gawk. go read them, they're all part of the same family. π«Ά
π AUTHOR π
Andrew Schorr, schorr@telemetry-investments.com. β¨
π COPYING PERMISSIONS π
Copyright Β© 2012, 2013, 2015, 2018, 2019, 2024, 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.
Free Software Foundation β’ Feb 25 2026 β’ INPLACE(3am)
and that's the whole page, bestie π mwah, go edit some files in place, but likeβ¦ responsibly. πβ¨
π¦ 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