pad
: command line text padding
Sometimes you have a command line sequence from which you need to cut
some columns. Sometimes getting that command to work right requires that you previously tr -s ' '
. Sometimes you have this solution all coded up before discovering the column -t
command.
In that case, you need pad
.
Usage
$ pad -h
pad 0.1.0
Peter Goodspeed-Niklaus <peter.r.goodspeedniklaus@gmail.com>
USAGE:
pad [OPTIONS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-a, --align <align>... Specify a column's alignment. May be repeated.
-d, --delimiter <delim> Specify the delimiter with which to distinguish input fields
-f, --file <file> Read from the named file instead of stdin
-s, --separator <sep> Specify the separator with which to separate output fields
If an input file is specified, that file is read. Otherwise, pad
reads from standard input.
The input is split into columns according to the delimiter, and space-padded such that every column has consistent width. It is then output with the separator separating the columns.
Columns are aligned left by default, though column alignment may be set per column using the -a
option:
- "l", "L", and "<" set left alignment
- "r", "R", and ">" set right alignment
- "c", "C", and "^" set center alignment
The -a
option must be specified once per column, and sets columns starting from the leftmost.
Examples
Basic usage
| | |
Set column alignment
| | |
Split and separate by a custom character
| |
Read from a file instead of stdin
Split/separate on an equals sign:
|