Simplify the problem by putting a third field at the beginning of the line:
cut -d ";" -f 3 file | paste -d ";" - file
then grep for the lines corresponding to the 3rd field, and remove the third field at the beginning:
grep "^215;" | cut -d ";" -f 2-
and then you can grep for whatever you want. So the complete solution:
cut -d ";" -f 3 file | paste -d ";" - file | grep "^215;" | cut -d ";" -f 2- | grep _your_pattern_
Advantage : easy to understand; drawback : many processes.
source share