File mod is a command line go utility to modify files. Below you can find the the availability and usage.
You can install the file-mod component for a specific OS at https://github.com/chef/file-mod/releases
Currently available for:
OS | ARCH |
---|---|
Darwin | x86_64 (amd64), arm64 |
FreeBSD | x86_64 (amd64) |
Linux | 386, x86_64 (amd64), arm64 |
Windows | x86-64 (amd64) |
You can optionally build file-mod via the goreleaser utility. Goreleaser uses a .goreleaser.yml
to define how you would like to build and release your go binary(ies).
Command line utility to modify files.
Usage:
file-mod [command]
Available Commands:
append-if-missing Append STRING to FILE if not already there.
find-and-replace Replace REGEX_STR with STRING in FILE. Supports multiline replace.
help Help about any command
Flags:
-h, --help help for file-mod
Use "file-mod [command] --help" for more information about a command.
This tool uses the regexp library under the covers.
# Update indented version reference in file (single line)
VERSION=$(cat VERSION)
file-mod find-and-replace "(?m)(\s+)VERSION = \".+\"" "\${1}VERSION = \"$VERSION\"" myfile.ext