SHTOOL-SUBST.TMP(1)
π SHTOOL-SUBST β the shtool-subst page, bestie edition π
okay so we're in the GNU Portable Shell Tool manual, and this little icon is shtool-subst. it's the GNU shtool sed(1) substitution operations situation. sit down, grab a boba, we're doing regex therapy π§β¨
πΈ NAME πΈ
shtool-subst β GNU shtool sed(1) substitution operations. that's it, that's the whole identity. it does the find-and-replace thing, but make it β¨infrastructureβ¨ π
π SYNOPSIS π
shtool subst [-v|--verbose] [-t|--trace] [-n|--nop] [-w|--warning]
[-q|--quiet] [-s|--stealth] [-i|--interactive] [-b|--backup ext]
[-e|--exec cmd] [-f|--file cmd-file] [file] [file ...]
like, that's a LOT of flags and honestly? she earned every single one. π«Ά
π¦ DESCRIPTION π¦
so basically: this command applies one or more sed(1) substitution operations to stdin or to any number of files. any number, bestie. zero files? she'll read stdin. forty files? she's got you. no cap. π₯
β¨ OPTIONS β¨
here are the command line options, and yes we're going through all of them because that's the vibe π
-v,--verboseβ spill some tea about what's happening: displays some processing information. π’-t,--traceβ turns on output of the essential shell commands that are being executed. so you can see exactly what she's running under the hood, iykyk π-n,--nopβ no operation mode. the essential shell commands that would be executed? yeah, actual execution of them is suppressed. she's just posing. π-w,--warningβ shows a warning on a substitution operation that results in no content change on every file. the default, though? the default is to show a warning on substitution operations that resulted in no content change on all files. yes those are different, yes it matters, read it twice π-q,--quietβ suppresses the warning on a substitution operation that results in no content change. silence. peace. no notes. π€«-s,--stealthβ stealth operation, periodt. preserves the timestamp on the file. she was never there. π₯·-i,--interactiveβ enters interactive mode, where the user has to approve each operation. yes, each one. consent-based sed, we love to see it π-b,--backup extβ preserves a backup of the original file using the file name extension ext. default is to overwrite the original file, which is giving brave π«£-e,--exec cmdβ specifies thesed(1)command directly. right there on the command line, out loud, in front of everyone π£οΈ-f,--file cmd-fileβ reads thesed(1)command from cmd-file. shy girl behavior, love that for her πΈ
π EXAMPLE π
okay here's the real-world stuff, and we're keeping it exactly as-is because code is sacred:
# shell script
shtool subst -i -e 's;(c) \([0-9]*\)-2000;(c) \1-2001;' *.[ch]
# RPM spec-file
%install
shtool subst -v -n \
-e 's;^\(prefix=\).*;\1 $RPM_BUILD_ROOT%{_prefix};g' \
-e 's;^\(sysconfdir=\).*;\1 $RPM_BUILD_ROOT%{_prefix}/etc;g' \
`find . -name Makefile -print`
make install
first one: interactive, inline command, hits all your *.[ch] files and does the year bump. second one: verbose + nop, two -e commands, and a backtick find feeding her every Makefile. that's range, that's versatility, that's main character energy β
π HISTORY π
the GNU shtool subst command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 2001 for GNU shtool. and why, you ask? because it was prompted by the need to have a uniform and convenient patching frontend to sed(1) operations in the OpenPKG package specifications. a legend saw chaos and said "not on my watch" π€π
π SEE ALSO π
and that's the whole page, bestie π«Ά this was shtool 2.0.8, dated 18-Jul-2008 β yes, she's vintage, yes she still slays, and the source is the GNU Portable Shell Tool, so go forth and substitute responsibly. mwah π πβ¨
π¦ where this page comes from
- debian bookworm: shtool 2.0.8-10 Β· GPL-2.0-or-later
- debian trixie: shtool 2.0.8-10 Β· GPL-2.0-or-later
- ubuntu jammy: shtool 2.0.8-10 Β· GPL-2.0-or-later
- ubuntu noble: shtool 2.0.8-10 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms