Text Utilities

/REQUIRE textutil.tf


The library file textutil.tf defines several unix-like commands that are particularly convenient when used with the %| pipe to redirect their input or output. For all commands that take an optional handle argument, tfin is used if handle is omitted.

/fgrep [-cvi] pattern
/grep [-cv] pattern
/egrep [-cvi] pattern
These commands search tfin for lines that match the given pattern, and by default prints those lines. For /fgrep, a line must contain pattern to match; for /grep, the entire line must match the glob pattern pattern; for /egrep, it must match the regexp pattern pattern.
Options:
-c
print only the count of matching lines.
-v
select only non-matching lines.
-i
ignore case (for /fgrep and /egrep only; /grep always ignores case).
Note: these commands are not compatible with those defined in the old library file grep.tf.

/readfile filename
Reads lines from filename and writes them to tfout.

/writefile [-a] filename
Reads lines from tfin and writes them to file filename.
Options:
-a
append to file instead of overwriting.

/head [-ncount] [handle]
Reads the first count (default 10) lines from handle or tfin and writes them to tfout.

/wc [-lwc] [handle]
Reads lines from handle or tfin and prints the count of lines, space-separated words, and characters that were read.
Options:
-l
Print the count of lines only.
-w
Print the count of words only.
-c
Print the count of characters only.

/tee handle
Reads lines from tfin and prints them to handle and tfout.

/copyio in out
Reads lines from handle in and prints them to handle out.

/fmt
Copies tfin to tfout, with adjacent non-blank lines joined.

/uniq
Copies tfin to tfout, with adjacent duplicate lines removed.

See: tfio, evaluation, substitution, oldgrep


Back to index
Back to tf home page
Copyright © 1998 - 1999 Ken Keys