SHTOOL-SUBST.TMP(1)

πŸ“¦
version 2.0.8 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– 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 the sed(1) command directly. right there on the command line, out loud, in front of everyone πŸ—£οΈ
  • -f, --file cmd-file β€” reads the sed(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