td-add-headers - Add headers to the tabular data stream and pass through the rows. |
td-add-headers - Add headers to the tabular data stream and pass through the rows.
td-add-headers <COLNAME_1> <COLNAME_2> ...
Add header row to the tabular data stream. Headers names will be the ones specified in the command line arguments, from the left-most 1-by-1.
If there are more fields in the first data row, then additional columns will be added with names like "COL4", "COL5", etc. by the index number of the column counting from 1. This may be prevented by --no-extra-columns option.
Name columns too which are not given name in the command parameters.
Do not add more columns than specified in the command parameters.
who | tr-trans | td-add-headers USER TTY DATE TIME COMMENT
td-alter - Add new columns and fields to tabular data stream, and modify value of existing fields. |
td-alter - Add new columns and fields to tabular data stream, and modify value of existing fields.
td-alter <COLUMN>=<EXPR> [<COLUMN>=<EXPR> [<COLUMN>=<EXPR> [...]]]
On each data row, sets field in <COLUMN> to the value resulted by <EXPR>
Perl expression.
In <EXPR>, you may refer to other columns by bareword or by
$Field{'COLUMN'}
if you must, where COLUMN is a column name.
You can create new columns simply by referring a <COLUMN> name not yet
existing.
You can use an earlier defined <COLUMN>'s value in a later defined
<EXPR>.
ls -l | td-trans-ls | td-alter TYPE='substr MODE,0,1' BIGFILE='SIZE>10000000 && TYPE ne "d" ? "yes" : "no"'
do not show headers
show headers (default)
td-filter - Show only those records from the input tabular data stream which match to the conditions. |
td-filter - Show only those records from the input tabular data stream which match to the conditions.
td-filter [<OPTIONS>] [--] <COLUMN> <OPERATOR> <R-VALUE> [<COLUMN> <OPERATOR> <R-VALUE> [...]]
td-filter [<OPTIONS>] --perl <EXPR>
Pass through those records which match at least one of the conditions (inclusive OR). You may put together conditions conjunctively (AND) by chaining multiple td-filter commands in the pipe. Example:
td-filter NAME eq john NAME eq jacob | tr-filter AGE -gt 18
This gives the records with either john or jacob, and all of them will be above 18.
td-filter(1) evaluates the Perl expression in the second form and passes through only if the result is true-ish in Perl (non zero, non empty string, etc). Each field's value is in @F by index, and in %F by column name. You can implement more complex conditions in this way.
do not show headers
show headers (default)
do not treat non-existing (missing or typo) column names as failure
only show warning on non-existing (missing or typo) column names, but don't fail
These operators are supported, semantics are the same as in Perl, see perlop(1)
.
== != <= >= < > =~ !~ eq ne gt lt
For your convenience, not to bother with escaping, you may also use these operators as alternatives to the canonical ones above:
is : string equality
is not, isnt, isnot : string inequality
-eq : numerical equality
-ne : numerical inequality
<> : numerical inequality
-gt : numerical greater than
-ge : numerical greater or equal
-lt : numerical less than
-le : numerical less or equal
match : regexp match
notmatch : negated regexp match
have, has : substring match
If there is no <COLUMN> column in the input data, it's silently considered empty. <R-VALUE> does not need quoting or escaping.
td-group - Collapse sorted tabular data stream's rows with equivalent first fields into one row. |
td-group - Collapse sorted tabular data stream's rows with equivalent first fields into one row.
td-group [<OPTIONS>]
It goes row-by-row and if 2 or more subsequent rows first (key) cell are the same then collapse them into one row. This is done by joining corresponding cells' data from each row into one cell, effectively keeping every column's data in the same column.
If you want to group by an other column, not the first one, then first
reorder the columns by td-select(1). Eg. td-select OTHERCOLUMN +REST
.
Separator character or string between joined cell data. Default is space.
This pipeline shows which users are using each of the configured default shells, grouped by shell path.
# get the list of users getent passwd |\ # transform into tabular data stream tr : "\t" |\ td-add-headers USER X UID GID GECOS HOME SHELL |\ # put the shell in the first column, and sort, then group td-select SHELL USER | td-keepheader sort | td-group -s ' ' |\ # change header name "USER" to "USERS" td-alter USERS=USER | td-select +ALL -USER
Have to sort input data first.
td-keepheader - Plug a non header-aware program in the tabular-data processing pipeline |
td-keepheader - Plug a non header-aware program in the tabular-data processing pipeline
td-keepheader [--] <COMMAND> [<ARGS>]
ls -l | td-trans-ls | td-select NAME +REST | td-keepheader sort | tabularize
td-pivot - Switch columns for rows in tabular data |
td-pivot - Switch columns for rows in tabular data
td-pivot
Must read and buffer the whole STDIN before output any data, so inpractical on large data.
td-select - Show only the specified columns from the input tabular data stream. |
td-select - Show only the specified columns from the input tabular data stream.
td-select [<OPTIONS>] [--] [-]<COLUMN> [[-]<COLUMN> [...]]
do not show headers
show headers (default)
do not treat non-existing (missing or typo) column names as failure
only show warning on non-existing (missing or typo) column names, but don't fail
warn and fail on non-existing (missing or typo) column names given in parameters, even if it's prefixed with hyphen, ie. when the user want to remove the named column from the output.
COLUMN is either a column name, optionally prefixed with hyphen, in which case the given column will not be shown, ie. removed from the shown columns, or one of these special keywords:
+ALL - all columns +REST - the rest of columns not given yet in the parameter list
So if you want to show all columns except one or two:
td-select +ALL -PASSWD
If you want to put a given column to the first place and left others intact:
td-select ID +REST
ls -l | td-trans-ls | td-select -- NAME +REST -INODE -LINKS -MAJOR -MINOR
td-trans - Transform whitespace-delimited into TAB-delimited lines ignoring sorrounding whitespace and make duplicated header names unique. |
td-trans - Transform whitespace-delimited into TAB-delimited lines ignoring sorrounding whitespace and make duplicated header names unique.
td-trans-ls - Transform ls output into fix number of TAB-delimited columns. |
td-trans-ls - Transform ls(1)
output into fix number of TAB-delimited columns.
ls -l | td-trans-ls
supported ls(1)
options which affect its output format:
unsupported options:
td-trans-mount - Transform mount output to tabular data stream. |
td-trans-mount - Transform mount(1)
output to tabular data stream.
Supported mount(1)
options which affect output format:
mount | td-trans-mount
mount -l | td-trans-mount
td2html - Transform tabular data stream into a HTML table. |
td2html - Transform tabular data stream into a HTML table.
td2html
Takes a tabular data stream on STDIN and outputs a HTML table
enclosed in <table>...</table>
tags.
td2mrkv - Transform tabular data into multi-record key-value format. |
td2mrkv - Transform tabular data into multi-record key-value (MRKV) format.
String to separate field name from content.
Default is TAB (\t
).
getent passwd | tr : "\t" | td-add-headers USER PW UID GID GECOS HOME SHELL | td-select +ALL -PW | td2mrkv