https://github.com/mklement0/grp-cli
a Unix CLI that facilitates breaking input into groups of characters
https://github.com/mklement0/grp-cli
cli grouping text-formatting text-parsing text-processing unix-cli
Last synced: 4 months ago
JSON representation
a Unix CLI that facilitates breaking input into groups of characters
- Host: GitHub
- URL: https://github.com/mklement0/grp-cli
- Owner: mklement0
- Created: 2015-06-13T03:09:34.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2022-12-27T14:10:13.000Z (over 3 years ago)
- Last Synced: 2025-10-08T21:43:27.449Z (8 months ago)
- Topics: cli, grouping, text-formatting, text-parsing, text-processing, unix-cli
- Language: Shell
- Size: 41 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://npmjs.com/package/grp-cli) [](https://github.com/mklement0/grp-cli/blob/master/LICENSE.md)
**Contents**
- [grp — Introduction](#grp-&mdash-introduction)
- [Examples](#examples)
- [Installation](#installation)
- [From the npm registry](#from-the-npm-registry)
- [Manual installation](#manual-installation)
- [Usage](#usage)
- [License](#license)
- [Acknowledgements](#acknowledgements)
- [npm dependencies](#npm-dependencies)
- [Changelog](#changelog)
# grp — Introduction
`grp` is a Unix CLI that facilitates breaking text into ***gr***ou***p***s of characters with a variety of options
and also offers formatting numbers with digit grouping (thousands separators) based on the active locale.
See the examples below, concise [usage information](#usage) further below, or read the [manual](doc/grp.md).
# Examples
```shell
# By default, break a string into space-separated groups of 3 chars.,
# starting from the right (end).
$ grp 1000000 2000
1 000 000
2 000
# Use proper number formatting (separation with locale-specific thousands
# separators) with -n; example output from the U.S. English locale:
$ grp -n 1000000 1999.99
1,000,000
1,999.99
# Break input into lines of 3 characters each, starting from the left:
$ grp -c 3 -s $'\n' -l abcdefgh
abc
def
gh
# Insert a '.' between characters:
$ grp -c 1 -s . abcdef
a.b.c.d.e.f
# Enclose each character in square brackets:
$ grp -c 1 -f '[%s]' abc
[a][b][c]
# Format text as a US telephone number:
$ echo '6085277865' | grp -f '+1 (%s) %s-%s' -c 3,3,4
+1 (608) 527-7865
# Break the input into repeating groups of 2 and 1 char. each:
$ grp -l -c 2,1+ -s / abcdefgh
ab/c/de/f/gh
```
# Installation
**Supported platforms**
* When installing from the **npm registry**: **Linux** and **OSX**
* When installing **manually**: any **Unix-like** platform with **Bash**
## From the npm registry
With [Node.js](http://nodejs.org/) or [io.js](https://iojs.org/) installed, install [the package](https://www.npmjs.com/package/grp-cli) as follows:
[sudo] npm install grp-cli -g
**Note**:
* Whether you need `sudo` depends on how you installed Node.js / io.js and whether you've [changed permissions later](https://docs.npmjs.com/getting-started/fixing-npm-permissions); if you get an `EACCES` error, try again with `sudo`.
* The `-g` ensures [_global_ installation](https://docs.npmjs.com/getting-started/installing-npm-packages-globally) and is needed to put `grp` in your system's `$PATH`.
## Manual installation
* Download [the CLI](https://raw.githubusercontent.com/mklement0/grp-cli/stable/bin/grp) as `grp`.
* Make it executable with `chmod +x grp`.
* Move it or symlink it to a folder in your `$PATH`, such as `/usr/local/bin` (OSX) or `/usr/bin` (Linux).
# Usage
Find concise usage information below; for complete documentation, read the [manual online](doc/grp.md) or,
once installed, run `man grp` (`grp --man` if installed manually).
```nohighlight
$ grp --help
Format numbers with digit grouping:
grp -n [-t ] [...]
Break text into groups of characters:
grp [-l | -r] [-c ] [-s | -f ] [-t ] [...]
Options:
-n apply locale-aware digit grouping to input numbers
-t terminator to append to each argument's result; default: \n
-l, -r start grouping from left / right (default)
-c count of chars. per group - may be comma-separated list
-s either: separator to place between groups; default: a space
-f or: printf-style format string to apply to groups
```
# License
Copyright (c) 2015-2016 Michael Klement (http://same2u.net), released under the [MIT license](https://spdx.org/licenses/MIT#licenseText).
## Acknowledgements
This project gratefully depends on the following open-source components, according to the terms of their respective licenses.
[npm](https://www.npmjs.com/) dependencies below have optional suffixes denoting the type of dependency; the *absence* of a suffix denotes a required *run-time* dependency: `(D)` denotes a *development-time-only* dependency, `(O)` an *optional* dependency, and `(P)` a *peer* dependency.
## npm dependencies
* [doctoc (D)](https://github.com/thlorenz/doctoc)
* [json (D)](https://github.com/trentm/json)
* [marked-man (D)](https://github.com/kapouer/marked-man#readme)
* [replace (D)](https://github.com/harthur/replace)
* [semver (D)](https://github.com/npm/node-semver#readme)
* [tap (D)](https://github.com/isaacs/node-tap)
* [urchin (D)](https://git.sdf.org/tlevine/urchin)
# Changelog
Versioning complies with [semantic versioning (semver)](http://semver.org/).
* **[v0.1.4](https://github.com/mklement0/grp-cli/compare/v0.1.3...v0.1.4)** (2016-06-05):
* [fix] When using `-n` to group numbers, the `-t` option is now respected.
* [enhancement] Improved detection of invalid numbers when using `-n`.
* **[v0.1.3](https://github.com/mklement0/grp-cli/compare/v0.1.2...v0.1.3)** (2015-09-17):
* [doc] `grp` now comes with a man page (invoke with `grp --man` in case of manual installation); `grp -h` now just prints concise usage info.
* **[v0.1.2](https://github.com/mklement0/grp-cli/compare/v0.1.1...v0.1.2)** (2015-09-15):
* [dev] Makefile improvements; various other behind-the-scenes tweaks.
* **[v0.1.1](https://github.com/mklement0/grp-cli/compare/v0.1.0...v0.1.1)** (2015-06-13):
* [doc] Read-me fixed and amended.
* **v0.1.0** (2015-06-13):
* Initial release.