I'm comparing two files, which are updated daily, with the diff -y
command in order to get two results:
The first are the lines that have been modified from one day to the next:
grupoAzul;Gabriel;04-maçãs;02-limões | grupoAzul;Gabriel;05-maçãs;02-limões
grupoAzul;Amanda;03-maçãs;05-limões grupoAzul;Amanda;03-maçãs;05-limões
For this, I use the command diff -y arquivoAntigo.csv arquivoNovo.csv | grep -e "|"
The second is the new lines:
grupoAzul;Gabriel;04-maçãs;02-limões | grupoAzul;Gabriel;05-maçãs;02-limões
grupoAzul;Amanda;03-maçãs;05-limões grupoAzul;Amanda;03-maçãs;05-limões
> grupoAzul;Kratos;04-maçãs;00-limões
For this result the diff -y arquivoAntigo.csv arquivoNovo.csv | grep -e">"
command is used.
Explain this, let's go to the error
When a new line appears above the modified line, diff 'pushes' the modified line down and considers it as the new line and what it was to be the new line it considers as modified line.
grupoAzul;Gabriel;04-maçãs;02-limões | grupoAzul;Kratos;04-maçãs;00-limões
> grupoAzul;Gabriel;05-maçãs;02-limões
grupoAzul;Amanda;03-maçãs;05-limões grupoAzul;Amanda;03-maçãs;05-limões
These events are, in fact, rare to happen but when they happen I have more than one line impaired.
What causes this bug and how can I fix it?