tools

various tools
git clone git://deadbeef.fr/tools.git
Log | Files | Refs | README | LICENSE

commit 656e0549bc31ca7ecccba74598a50f5db2d98343
parent 1c15eed4a2b2433e9e4e826ed38a5dcb760f7fdd
Author: Morel Bérenger <berenger.morel@neutralite.org>
Date:   Tue, 25 Feb 2020 20:51:04 +0100

added a manpage (needs pandoc) and a Makefile to build it

Diffstat:
AMakefile | 4++++
Amerge.1.md | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -0,0 +1,4 @@ +%.1: %.1.md + pandoc -s --to=man $< -o $@ + +manpages: merge.1 diff --git a/merge.1.md b/merge.1.md @@ -0,0 +1,68 @@ +% merge(1) merge manpage +% Bérenger Morel +% 2020-02-25 + +# NAME + +*merge* - merges entries with common fields + +# SYNOPSIS + +`cat foo | *merge*` + +# DESCRIPTION + +Merges consecutive entries when they share a common field. +Entries are read from stdin. + +*merge* does not remove duplicated fields. + +# OPTIONS + +For now, options are managed through environment variables: + +FIELDS + +: list of indexes (starting from 0, separated with **commas** (\',\', 0x2C) of +the fields that will be compared. + +FIELD_SEP + +: list of characters that will be considered as field separators. +Defaults to **space** (\' \', 0x20) and **horizontal tabulation** (\'\\t\', 0x09). + +ENTRY_SEP + +: list of characters that will be considered as entry separators. +Defaults to **newline** (\'\\n\', 0x0A). + +# EXAMPLE + +This invocation: + +```sh +FIELD_SEP=": \t" FIELDS="1,3" ./merge <<EOF +0 foo:hello:1 +1 bar:hello:2 + 2:foo:world:3 + 2:bar:world:4 +EOF +``` + +will generate this result: + +``` +0 foo:hello:1 +1 bar:hello:2 + 2:foo:world:3: 2:bar:world:4 +``` + +# BUGS + +Multi-byte characters can not be used for FIELD_SEP and ENTRY_SEP. + +# TODO + +Allow the use of command-line parameters to configure behavior. + +# SEE ALSO