Skip to content

chef/file-mod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

file-mod

File mod is a command line go utility to modify files. Below you can find the the availability and usage.

Installation

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)

Build

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).

file-mod

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.

find-and-replace Sample Usage

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