soveran / ers

AWK script easy replacements in templates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ers -- Easily replace strings in templates

Description
-----------

Given a file with %tags%, replace each tag with the value passed
in the command line.

Example
-------

If you have the following template:

	$ cat example.txt
	%foo% %bar%

You can replace the tags with this command:

	$ ers example.txt foo=1 bar=2

The result will be printed to standard output.

If you want to replace strings in standard input instead, just pass
`-` as the file argument:

	$ cat example.txt | ers - foo=1 bar=2

The result will be the same as in the previous example.

Installation
------------

Make sure you have `awk` in your system, then run `make` to create
the `ers` executable, and copy it anywhere in your path.

The reason for building the file this way is because the shebang
in `ers` needs to pass the `-f` flag to `awk`. Using the usual
`/usr/bin/env awk -f` would be problematic, because it's not POSIX
and it doesn't work on Linux. Therefore when building the script
we use the direct path to `awk` in the shebang, e.g. `/bin/awk -f`.

About

AWK script easy replacements in templates


Languages

Language:Awk 71.6%Language:Makefile 28.4%