8000 GitHub - cwilper/replacevars: Replace environment variable references in a file
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cwilper/replacevars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

replacevars

Replace environment variable references in a file.

Installation

Download the script, make it executable, and put it in your PATH.

You can also source the script and use as it a bash function, avoiding the need to export variables.

Usage

replacevars [-t] ( -f file | -i file | - ) [ldelim] [rdelim]

Where:

  • -t prints variables in the input in the order they appear, and exits (for testing)
  • -f gets input from a file and prints the result to stdout
  • -i gets input from a file and overwrites it with the result
  • - gets input from stdin and prints the result to stdout
  • ldelim is the left delimiter for variable references (default is {{)
  • rdelim is the right delimiter for variable references (default is }})

Examples

  command> echo "Hi {{first}} {{last}}" | replacevars -
   stderr> Undefined variable: first

  command> echo "Hi {{first}} {{last}}" | first=Some last=Person replacevars -
   stdout> Hi Some Person

     file> Hi ${first} ${last}
  command> first=Some last=Person replacevars -f file '${' '}'
   stdout> Hi Some Person

     file> Hi {{first}} {{last}}
  command> first=Some last=Person replacevars -i file
     file> Hi Some Person
   stdout> 2 variables replaced in file

     file> Hi Some Person
  command> first=Some last=Person replacevars -i file
     file> Hi Some Person
   stdout> 0 variables replaced in file

About

Replace environment variable references in a file

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

0