Hi I wish to alternately change some of the data in the following way. For example I wish to switch all species from their current value to their binary opposite. I.e. from 1 -> 0 and from 0 -> 1 when the LIPID number is even. Now the data is on the file such that the LIPID number is before the SPECIES number. Therefore I came up with the following sed script to attempt to do this. However this script doesńt work when there is information/data between the LIPID and the SPECIES but seems to work just fine otherwise. Here is the script and the data file:

LIPID 0
SPECIES 0
5435345
LIPID 1
SPECIES 1
435345.4544
LIPID 2
SPECIES 1
22.78
LIPID 3
SPECIES 1
22.78
LIPID 4
SPECIES 1
22.78
LIPID 5
SPECIES 1
LIPID 6
SPECIES 1

sed '
/[02468]$/ {N
s/SPECIES 1/SPECIES 0/
}' Test1.txt > OP.txt;
mv OP.txt Test1.txt;