XCUT - a filter to chop up a file


Freeware by David Mitchell - dave@zenonic.demon.co.uk

Function

This filter performs a very simple parsing operation on a file. It splits the file into three parts:

  1. the part before a given repetition of a given (hex) string
  2. the given string
  3. the part after the given string

The output file can be made up of any combination of these three parts (though always in the order 1,2,3). By default it's just 1.

Usage

Because XCUT uses the standard input and standard output files which are by default the keyboard and screen, you have to use redirection if you want files XCUTed:

       XCUT <infile >outfile hexstring /parts /rcount

The hex string is specified by an h or H followed by a series of hex digits. Blanks are allowed within the string. If no hexstring is supplied, XCUT will display short help.

There are two options. The first consists of / followed by a combination of the digits 1,2 and 3. If a particular digit is present XCUT will copy that part to the output file. The default is 1.

The second consists of /r followed by a decimal number between 1 and 64k. This is the number of repetitions of the string which must be found before XCUT splits the file. The default is 1.

Note that the order of options is irrelevant. They can come before or after the hex string. A '-' can be used instead of a '/' to start an option.

Thus to remove the first occurrence of the string h 0d 0a 1a (this is the Carriage Return/Line Feed/Control-Z sequence that some old text editors put at the end of all files) from the file TESTIN and put the result in TESTOUT, any of the following would do:

       XCUT <TESTIN >TESTOUT h 0d 0a 1a /13
       XCUT <TESTIN >TESTOUT h 0d 0a 1a /31
       XCUT >TESTOUT h0d0a1a <TESTIN -13

To put the first 100 lines of the file TESTIN into TESTOUT this would do:

       XCUT <TESTIN >TESTOUT  /r100 h0d0a

Restrictions