Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seanbreckenridge/chomp
CLI tool that removes whitespace/empty lines from command output
https://github.com/seanbreckenridge/chomp
Last synced: 25 days ago
JSON representation
CLI tool that removes whitespace/empty lines from command output
- Host: GitHub
- URL: https://github.com/seanbreckenridge/chomp
- Owner: seanbreckenridge
- License: mit
- Created: 2021-01-07T01:50:59.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-16T02:59:50.000Z (over 1 year ago)
- Last Synced: 2024-08-02T15:47:38.007Z (3 months ago)
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## chomp
```
usage: chomp [-h] [FLAGS]Receives input from STDIN
Removes extra whitespace characters from the beginning/end of lines
Removes lines which have just whitespace (no content)Flags:
-max-capacity int
Maximum capacity for each line in kilobytes. Can also set through CHOMP_MAX_CAPACITY environment variable. (default 64)
```This is essentially a portable (and 3x faster):
```
sed -E -e 's/^\s*//; s/\s*$//; /^\s*$/d'
```[I use this in scripts](https://gist.github.com/seanbreckenridge/02bf00bc50b3ad6a35088fb75e41e9e6) when trying to remove spaces from user input/command output. Its also often helpful when data wrangling, to be able to quickly ignore lines/spaces I'm not interested in.
### Install
Using `go install` to put it on your `$GOBIN`:
`go install github.com/seanbreckenridge/chomp@latest`
Manually:
```bash
git clone https://github.com/seanbreckenridge/chomp
cd ./chomp
go build .
# copy binary somewhere on your $PATH
sudo cp ./chomp /usr/local/bin
```### Example
Typically this would be used by piping some command into it:
```
$ man -P cat rm | head
RM(1) User Commands RM(1)NAME
rm - remove files or directoriesSYNOPSIS
rm [OPTION]... [FILE]...DESCRIPTION
This manual page documents the GNU version of
``````
$ man -P cat rm | head | chomp
RM(1) User Commands RM(1)
NAME
rm - remove files or directories
SYNOPSIS
rm [OPTION]... [FILE]...
DESCRIPTION
This manual page documents the GNU version of
```