|
Splitting a file |
Pipelines v1.6 |
.* Example by TenFiftyTwo(c). |
.* The following pipeline reads the FetchMail logfile: CMM-50_plldp.log and extracts each.* group/set of monitor records; based on an ACT label: BC#, CP# and the 'Average' entries..* For each log section found; the pipeline creates/appends that set of records to a file.* with the name of that section.
.* The pipeline is intended to demonstrate how you can isolate sections of a file,.* and split off and create/append those sections to a specific output file. pipe (stagesep | endchar ? escape %)
.* Input file. < &installdrive:\&installpath\Examples\Input\CCM-50_plldp.log | specs 1-* 1 xff n .* Append an x'ff' to each record. | a: locate .* Select records that comprise a BC# or CP#. anycase w-1 reg /BC([0-9])%|CP([0-9])/ .* Surround the output filename with quotes ("). | specs /"&sysdrive:\Documents and Settings\&username\My Documents\/ 1 ws xff20 w-1 n \.log"\ n 1-* nw | specs /@/ 1 1-* n .* Prepend an (@) character. | split after str /@/ .* Split records after the (@) character. | b: faninany .* Join the streams. | join until str /@/ .* Collect records until we read a record.. .* ..which starts with an (@) character. | locate .* Discard blank lines. | locate 1 /"/ .* Select records that begin with a quote ("). | split before str /</ .* Split records that begin with a (<).. | nlocate 1 /</ .* ..and discard them. | change xff x0a .* Change x'ff's to newline characters. | cons .* Display on the console. | >> .* Append this section to the output file. ? a: | j: locate anycase w1 /average/ .* Select records that begin with: 'average'. | specs /"&sysdrive:\Documents and Settings\&username\My Documents\/ .* Surround.. 1 w1 n \.txt"\ n 1-* nw .* ..the output filename with quotes. | specs /@/ 1 1-* n .* Prepend an (@) character. | split after str /@/ .* Split records after the (@) character. | k: faninany .* Join the streams. | b: .* Send the records back to the first pipeline. ? j: | take * .* Handle unselected records from second pipeline. | k: