Q:

Filtering Input files

So I'm trying to filter 'duplicate' results from a file. 
Ive a file that looks like: 
7 14 35 35 4 23
23 53 85 27 49 1
35 4 23 27 49 1
....

that I mentally can divide up into item 1 and item 2. Item 1 is the first 3 numbers on each line and item 2 is the last 3 numbers on each line. 
I've also got a list of 'items':
7 14 35
23 53 85
35 4 23
27 49 1
...

At a certain point in the file, lets say line number 3 (this number is arbitrary and for example), the 'items' can be separated. Lets say lines 1 and 2 are red and lines 3 and 4 are blue. 
I want to make sure on my original file that there are no red red or blue blues - only red blue or blue red, while retaining the original numbers. 
So ideally the file would go from:
7 14 35 35 4 23 (red blue)
23 53 85 27 49 1 (red blue)
35 4 23 27 49 1 (blue blue)
....

to
7 14 35 35 4 23 (red blue)
23 53 85 27 49 1 (red blue)
....

I'm having trouble thinking of a good (or any) way to do it. 
Any help is appreciated. 
EDIT:
An filtering script I have that grabs lines if they have blue or red on the lines:
#!/bin/bash

while read name; do
  grep "$name" Twoitems
done < Itemblue > filtered

while read name2; do
  grep "$name2" filtered
done < Itemred > double filtered

EDIT2:
Example input an item files: 

A:

This is pretty easy using grep with option -f.
First of all, generate four 'pattern' files out of your items file.
I am using AWK here, but you might as well use Perl or what not.
Following your example, I put the 'split' between line 2 and 3; please adjust when necessary.
awk 'NR <= 2 {print "^" $0 " "}' items.txt > starts_red.txt
awk 'NR <= 2 {print " " $0 "$"}' items.txt > ends_red.txt

awk 'NR >= 3 {print "^" $0 " "}' items.txt > starts_blue.txt
awk 'NR >= 3 {print " " $0 "$"}' items.txt > ends_blue.txt

Next, use a grep pipeline using the pattern files (option -f) to filter the appropriate lines from the input file.
grep -f starts_red.txt  input.txt | grep -f ends_blue.txt > red_blue.txt
grep -f starts_blue.txt input.txt | grep -f ends_red.txt  > blue_red.txt

Finally, concatenate the two output files.
Of course, you might as well use >> to let the second grep pipeline append its output to the output of the first.

