XFILTER
— Process lines of a
file using variable expansion.
Syntax:
XFILTER
/A:
attribs /B /CP:
n /F:"
format"
/H /N /P /S /T
filename…
/A: attribs | attributes mask; valid flags are -ACEHIORS |
/B | discard blank lines |
/CP: n | interpret non-Unicode input text using code page n |
/F:" format" | format string: required; see below |
/H | display filenames |
/N | disable features |
/P | page output |
/S | search in subdirectories for matching files |
/T | trim leading and trailing whitespace |
… | Range options are also supported. |
The required format
string contains TCC variables and functions, which will be expanded for each
line in the file. Double all percent signs to prevent variables from being
expanded before the command is executed. An asterisk in the format
string will be replaced with each line from the file. The current (zero-based)
line number is also available in the variable _LINE
.
XFILTER
can be used as a filter reading from standard input, or
it can read from one or more files specified on the command line. The resulting
text is written to standard output; it can be piped or redirected. If you want
to pipe to XFILTER
, remember that pipes open a new shell. To pipe
to a plugin command, you must either ensure that the plugin is loaded in the
transient shell, e.g. by installing the .DLL
file in the shell’s PlugIns directory; or
else use temporary files or an in-process pipe.
You may specify more than one filename; wildcards
and directory aliases are supported. You can search recursively into subdirectories
for matching files with /S
. @File lists and internet files are
supported. You may also specify CLIP:
to process text from the
clipboard instead of from a file.
To prevent problems caused by troublesome characters in the input text, certain ‘dangerous’ characters from the file will be temporarily replaced with safe alternatives from Unicode’s Halfwidth and Fullwidth Forms block. They will be restored to ASCII after variable expansion. This shuffle prevents issues when characters with special meanings to TCC are inadvertently present in the input text, but it might be confusing if you want to find or replace any of the remapped characters. The characters which are temporarily replaced are:
Character | ASCII | Hex | Remapped to |
" | 34 | 22 | U+FF02 |
% | 37 | 25 | U+FF05 |
( | 40 | 28 | U+FF08 |
) | 41 | 29 | U+FF09 |
, | 44 | 2C | U+FF0C |
[ | 91 | 5B | U+FF3B |
] | 93 | 5D | U+FF3D |
^ | 94 | 5E | U+FF3E |
` | 96 | 60 | U+FF40 |
rem Dump a file in uppercase:
xfilter /f:"%%@upper[*]" "Engine Summer.txt"
rem Display the length of each line:
xfilter /f:"Line %%_line has %%@len[*] characters." "Engine Summer.txt"