print-columns
Quick Start
- Command:
print-columns 'awk_print_expression' - Local executable:
/home/vimalinx/miniforge3/envs/bio/bin/print-columns - I/O shape: reads tab-delimited stdin and emits the requested fields on stdout
When To Use This Tool
- Project or reorder tab-delimited columns without writing a full
awkcommand each time. - Add lightweight arithmetic or string transforms inside an EDirect shell pipeline.
- Stamp output with the current year (
YR) or date (DT) via the wrapper's built-in variables. - Quickly quote or lowercase specific fields before piping into another shell utility.
Common Patterns
# 1) Reorder columns and add arithmetic
printf '1\t2\t3\n' | print-columns '$1, $2+1, YR, DT'
# 2) Quote a selected field
printf 'geneA\t42\n' | print-columns '$1, "\"" $2 "\""'
# 3) Lowercase and keep selected columns from an upstream extractor
xtract -pattern DocumentSummary -element Name,Status,CreateDate |
print-columns '$1, tolower($2), $3'
Recommended Workflow
- Make sure the incoming stream is tab-delimited, because the wrapper hard-codes
-F '\t'. - Write the desired
awkprint expression and wrap it in single quotes so the shell does not expand$1,$2, and friends. - Pipe stdin into
print-columnsand verify that the transformed columns still line up with downstream expectations. - Use the built-in
YRandDTvariables when you need run-date metadata without callingdateyourself.
Guardrails
- The expression is injected directly into
awk "{print ...}"; if you forget shell quoting,$1and similar fields will be expanded by the shell and the command can break with anawksyntax error. - There is no real option parsing or built-in help path;
print-columns --helpwith no stdin produces no useful output. - The wrapper is stdin-oriented and does not support separate filenames or flags in the usual
awkstyle. - Field splitting is always tab-based, not whitespace-generic.
- The wrapper defines
YRas the current year andDTas the currentYYYY-MM-DDdate for use inside the print expression.