@achannarasappa/sub
[![Build Status](https://travis-ci.org/achannarasappa/sub.svg?branch=master)](https://travis-ci.org/achannarasappa/sub)
Last updated 2 years ago by achannarasappa .
MIT · Original npm · Tarball · package.json
$ cnpm install @achannarasappa/sub 
SYNC missed versions from official npm registry.

sub

Build Status

Installation

TBD

Usage

sub <file_pattern> [options...]

Shell-esque parameter substitution in files from env and text data sources

Positionals:
  file_pattern  file glob pattern e.g. *.json                           [string]

Options:
  -i, --in-place             Edit files in place                [default: false]
  -d, --dry-run              Make no substitution               [default: false]
  -c, --count-substitutions  Output substitution counts         [default: false]
  -v, --version              Show version number                       [boolean]
  -h, --help                 Show help                                 [boolean]

Examples

Pipe from and to stdio

echo 'Hello my name is ${USER}\nI live in ${HOME}' > greeting.txt
echo 'USER=rob\nHOME=philadelphia' | sub greeting.txt
# Hello my name is rob
# I live in philadelphia

Replace files in place and count replacements

echo 'Hello my name is ${USER}\nI live in ${HOME}' > greeting.txt
echo '${USER} speaks ${LANGUAGE}' > language.txt
env | grep 'USER\|LANGUAGE\|HOME'
# USER=ani
# HOME=/home/ani
# LANGUAGE=en_US
sub *.txt --in-place --count-substitution
# greeting.txt
#  USER: 1
#  HOME: 1
# language.txt
#  USER: 1
#  LANGUAGE: 1
cat greeting.txt
# Hello my name is ani
# I live in /home/ani
cat language.txt
# ani speaks en_US

Contributions

PRs welcome :)

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

1 Versions

  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 1
Last Month 3
Dependencies (8)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |