FLDS(1): print fields
USAGE
usage: flds [-1Du] [-F sep] [-o sep] {-r range} {file}
-1: fields separated by 1 run of the field delimiter string
-D: debug
-F sep: input field delimiter character(s) (or string under -1)
-o sep: output field delimiter string
-r range: print this range
-u: use unix out
DESCRIPTION
Flds prints the requested fields for the given files. Fields are specified as ranges. A range may be a single line number, counting from 1, or a pair of start and end field numbers separated by a ",
" character. Negative field
numbers count backwards from the end of the line (the last is
-1
and so on).
Multiple ranges may be given. A missing start number in a range means
1
, and a missing end number in a range means
-1
. If no range is given,
",
" is implied. And, when such range is
indicated, all fields are printed, one line at a time.
By default the field separator is a run of blanks. Flag
-F
changes the set of runes used as field
separators to its argument.
Flag -1
indicates that fields are separated
exactly by one instance of the separator string. Such string defaults
to a tabulator character in this case, unless
-F
says otherwise.
Fields are printed in the order indicated by the ranges given (first
range gets printed first). Output fields are separated by default
using a tab character or the sep
string if
-1
is used.
EXAMPLES
Print the first two fields and the last one from theps
output:
; ps | rf | flds -u -r 1,2 -r -1
In a file with fields separated with ":
",
and, perhaps with empty fields, print just the first and third fields
in reverse order:
; ps | rf | flds -u -1F: -r 3 -r 1
Replace the field separator ":
" with
",
" in all files under the current directory
and update those files on disk:
; gf , | flds -u -1F: -o, | pf -w
SOURCE
/zx/sys/src/clive/cmd/flds