On Mon, 4 Feb 2019 at 16:19, Tim Joyce <tim.jo...@alexlee.com> wrote:
> > It has been requested that I also output the line/record number that the > string was found on (as some members locate strings in multiple locations). > I have been looking through pipelines reference but have not figured out > the best way to do this without a lot of additional preprocessing of input > data. Any suggestions would be appreciated. > > To add a record number to your input data, you'd use for example SPEC like this, just after the "<" stage that reads the data: ' | spec number 1.10 r 1-* nw ' Since the first 10 bytes of each record are now the line number, you need to restrict your LOCATE stage to the remainder of the record: ' | locate anycase 12-* ~'strg'~' The SPEC that decorates your matching lines with the file name will now show the line number before the contents of the line. The entire thing will be 11 byte longer. You can re-arrange the fields there to change the decoration. Note: Using REXX substitution for the string in the LOCATE is fragile and risky. You might want to encode the search string in hex. Sir Rob the Plumber