We are running parallel reports with Legacy vs a new system and want to compare certain lines with the diff or diff -b command. When a six digit number is read at the beginning of the line (no decimal point) we read and ignore a header line (next), move any minus sign to the end of the number and, if the next line starts with "Today", a line with the six digit number, a "|" symbol and the rest of the line is created. This is the sed script we use:
/^[0-9][0-9][0-9][0-9][0-9][0-9][^\.]/{
N
s/\n.*//
N
s/\n/|/
s/-\([\.0-9]*\)/\1-/g
/Today/p
}
If there was no business done, the new system replaces 0.00 twice with a line break. We need to change:
When business is done, the line starting with "Today" will be followed by a count and ten two-digit numbers (percents or dollar amounts)--my problem is when the count is zero and certain 0.00 are replaced with a new line.
This is what the set of data looks like:
123456
Constant column headings are on this line and will be ignored
Today 0 0.00 0.00 ... etc
-------------- output ----------------
123456 |Today 0 0.00 0.00 0.00 etc -2236.93
I have been experimenting with this sed script as a new first step:
Your data sample show a first line with 6 digits, whereas your sed script in post#1 tests for 6 digits followed by any character that is neither . or a \ . So the script will not match the first line of your data sample.
The "\" was to escape the decimal point so I wanted six digits not followed by a decimal point. That got rid of my false positive using SCO Unix. Six digits with nothing else on the line was the only thing I was interested in.
That didn't fly the first time but then I discovered a trailing space after all the valid six digit numbers, so adding a space before the $ fixed it.
I didn't realize a period didn't need to be escaped when in a bracket. In the first code in my OP on the last s command (ends with /g), I took out the " \ " with no ill effects.