DragonFly On-Line Manual Pages

Search: Section:  


fldfmt(1)(TDH)                                                  fldfmt(1)(TDH)

NAME

fldfmt(1) - take a tabular data stream and format, add new field, or modify a field

SYNOPSIS

fldfmt [options] [formatstring]

DESCRIPTION

fldfmt is a filter utility that selects fields from a stream of records and outputs them to standard output. It can be used to build human- presentable reports, or to process data. Data records should be white- space delimited, tabular ascii format. One output record is produced for every input record. Use it in one of these modes: format mode: Create formatted rows. Fields will be presented as specified in a formatstring argument (or format file when -f is used). This is the default mode. You'll probably want to also use -dp for data processing purposes. new field mode: all fields will be output, along with one new field. See -newfield below modify field mode: all fields will be output, with one of them changed to a constant value. See -modfield below

FORMAT MODE

formatstring (or the format file) may contain data field @names or field @numbers as in the examples below. Inline formatting codes , all of which begin with colon (:) may also be used. Everything else in formatstring is passed through transparently. formatstring may actually be up to 3 command line arguments, which fldfmt will concatenate together. This allows long formatstrings to be split up for readability.

OPTIONS

-h Header mode. Data field names are expected in the first non- comment non-blank line, separated by white space. The formatstring can then access fields by @name, instead of just by @number. -t Input fields expected to be tab-delimited. With -newfield or -modfield, output fields will also be tab-delimited. -f formatfile Output format specification will be taken from formatfile instead of the command line; same syntax expected. Upper limit of 3000 characters. -dp Data processing mode. Equivalent to -u -c. This is normally what is desired when doing data processing, ie. when the output is not for presentation to humans. -u Show embedded underscores found in data fields. Normally they are converted to spaces. Underscore conversion may also be controlled within formatstring using inline formatting codes :u+ and :u-. -c Show nulls literally. Normally nulls are displayed as a zero length string. Null representation may be controlled from the project config file. -newfield fieldpos# contents Output all fields, and add a new field at position fieldpos# containing contents. Implies -dp. No formatstring is accepted. Example: to add a new field containing abc at the beginning of each output record use fldfmt -newfield 1 "abc" -modfield fieldpos# contents Output all fields, and modify the field at position fieldpos# so that it will contain contents. Implies -dp. No formatstring is accepted. Example: to change the 3rd field such that it contains abc on each output record, use fldfmt -modfield 3 "abc" -l Turn off evaluation of inline formatting codes -s Suppress data-less lines. For lines that contain at least one variable, and that had all variables evaluate to "" (nothing), the entire line is suppressed. If format is more than one line, individual lines are handled separately. -bh Output a bogus field name header as the first output line. May be useful in situations where a header line is expected but not used.

EXAMPLES

cat mydata | fldfmt "@1 (@2)" cat mydata | fldfmt "@1 @2 :dec28 @4" cat scores | fldfmt -h "Name: @firstname @lastname :col40 Score: @score" cat scores | fldfmt -newfield 3 "=" cat scores | fldfmt -modfield 6 "d" The following example makes html table rows containing hyperlinks. Assumes that CGIPROG is defined to the URL of the CGI executable using varvalue in the tdh config file. fldfmt "<td><a href=\"@CGIPROG?rtn=people/details&id=@id\"> @fname @lname</a></td></tr>"

SEE ALSO

fldsel(1) , another TDH utility can select and omit fields 19-SEP-2003 TDH scg@jax.org fldfmt(1)(TDH)

Search: Section: