DataReelDataReelC++ Toolkit Documentation

txfilter

Text filter (back in DataReel 7.4, from 6.x).

Contents

Usage
Examples

Usage

txfilter [switches] file...
  -P  printable characters only (default)   -A  alphabetic   -M  alphanumeric   -N  numeric
  -t  remove tabs   -s  remove spaces   -n  no filtering
  -u  UNIX line ends (default)   -d  DOS (CR LF)   -D  none
  -o  write the result over the file (default: standard output)

Lines may be of any length. -P keeps bytes 0x80 and up, so UTF-8 text survives. -o writes through a temporary file and a rename.

Examples

report.txt came from a Windows program: DOS line ends, a tab and a control character (0x01) on the last line. cat -A shows a tab as ^I, a carriage return as ^M, 0x01 as ^A and a line end as $:

$ cat -A report.txt
Order 1001^IAMTX^M$
Total: 3.25^M$
Note:^A done^M$

The printable characters with UNIX line ends, to standard output:

$ txfilter report.txt | cat -A
Order 1001^IAMTX$
Total: 3.25$
Note: done$

$ txfilter -t report.txt | cat -A
Order 1001AMTX$
Total: 3.25$
Note: done$

Clean the file in place and keep DOS line ends:

$ txfilter -d -o report.txt
$ cat -A report.txt
Order 1001^IAMTX^M$
Total: 3.25^M$
Note: done^M$

For terminal color and cursor codes (ESC sequences) in program output use strip_ansi() of strutil.h; txfilter removes the ESC character but keeps the rest of the sequence.