Using GNU awk:
awk '{ for (i=1;i<=NF;i++) { fnd=0;subs=$i;while (match(subs,"ATTCGACCGATAGG")) { subs=substr(subs,RSTART+RLENGTH);if (RSTART>0) { fnd++;print fnd } } if (fnd <=2) { print $i } } }' file
Explanation:
awk '{ for (i=1;i<=NF;i++) { # Loop on each space delimited field
fnd=0; # Initialise fnd variable/counter
subs=$i; # Initialise substring variable
while (match(subs,"ATTCGACCGATAGG")) {
subs=substr(subs,RSTART+RLENGTH); # Check for multiple matches of "ATTCGACCGATAGG" in subs.
if (RSTART>0) {
fnd++; # Increment fnd if string found in subs
}
}
if (fnd <=2) {
print $i # If found twice or less than twice print the field
}
}
}' file
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…