man8db/WStrim

Table of Contents

Name

WStrim - trim whitespace and reformat tuples

Synopsis

WStrim <long options> trim_spec_file < in_file > out_file

Description

This program reads a list of tuples from stdin. It removes leading and trailing whitespace from each field within the tuple, processes the field according to the rules given in the trimspec file and writes the result to stdout.

Arguments

Most of the argument processing is done using Unix long argument syntax.

The trim_spec_file argument is required and must always be present following the long options.

The program normally performs it’s work silently. It doesn’t even print a sign on message.

Use the --help option to obtain a list of commands supported by the program.

--verbose=<n>

A verbosity level. The argument is optional. If not provided the verbosity level defaults to 1. This causes the program to print the signon message and the option table.

Note that because the argument is optional the equals sign must be present when the argument is used.

--help

Print the program help to stderr and exit.

Input Tuple

Each input line is one tuple. The line is terminated with a newline. Fields within the tuple are separated by a |.

Trimspec File

This file contains a specfication of how to treat each field within a tuple. Each line in the file contains information about one field within a tuple. The lines in the trimspec file are in the order of the fields within a tuple.

Each line consists of a number which specifies the width of the field. Incoming tuples are processed to remove leading and trailing whitespace. The field is output with the width given by the trimspec file. The output is repadded with whitespace if necessary to make the field the width specified by trimspec. If the trimspec value is negative the output is left justified with trailing whitespace added as necessary, otherwise leading whitespace is added.

Comments begin with a # and may appear anywhere in the trimspec file.

Example

Here is an example trimspec file:
4    # recid
-10    # label
10    # refname

Here is example input:
10|hell |oh
10|hell | oh

Manual page revision

$Id: WStrim.8,v 1.1 2007/09/13 16:50:32 kitchen Exp $


Table of Contents