field_just - Linux


Overview

field_just is a versatile command-line tool for aligning, justifying, and otherwise manipulating text fields. It is commonly used for formatting tabular data, aligning output for visual clarity, and preparing text for different purposes.

Syntax

field_just [options] [parameters] filename

Options/Flags

| Option | Description | Default |
|—|—|—|
| -a, --align | Alignment: left, right, center | left |
| -c, --columns | Number of columns | 1 |
| -d, --delimiter | Field delimiter | Space |
| -f, --format | Output format: raw, table | table |
| -h, --help | Display help information | – |
| -i, --indent | Indentation before each line | 0 |
| -j, --justify | Justification: left, right, center, full | left |
| -l, --lines | Number of lines | 1 |
| -n, --number | Add line numbers | false |
| -s, --separator | Column separator | Pipe (|) |
| -t, --trim | Trim leading and trailing whitespace | false |
| -w, --width | Column width | 10 |

Examples

Align text to the right:

field_just -a right filename.txt

Create a table from a delimited file:

field_just -d ',' -f table filename.csv

Justify text in the center:

field_just -j center filename.txt

Trim leading whitespace and add line numbers:

field_just -t -n filename.txt

Common Issues

  • Empty or nonexistent file: Ensure that the provided file exists and contains data.
  • Incorrect alignment or justification: Check the specified alignment or justification options.
  • Mismatched number of columns and lines: Adjust the -c and -l parameters to match the actual data.

Integration

Pipe output to other commands:

field_just -f raw filename.txt | sort

Use as part of a script:

#!/bin/bash

# Extract specific columns from a CSV file
field_just -d ',' -c 2,4 filename.csv

Related Commands

  • column
  • cut
  • paste
  • sed