Dear All,
Here is my input
TAACGCACTTGCGGCCCCGGGATAAAAAAAAAAAAAAAAAAAAATGGATT
NAGAGGGACGGCCGGGGGCATAAAAAAAAAAAAAAAAAAAAAGGGATTTC
NGGGTTTTAAGCAGGAGGTGTCAAAAAAAAAAAAAAAAAAAAAGGGATTT
NTGGAACCTGGCGCTAGACCAAAAAAAAAAAAAAAAAAAATGGATTTTTG
ATACTTACCTGGCAGGGGAGATACCATGATCAATAAAAAAAAAAAAAAAA
NACAAAGCATCGCGAAGGCCCGCGGCAAAAAAAAAAAAAAAAAATGGGAT
When I try this command
cat 1 | grep AAAAAAAAAAAAAAAAAAAAA
I get this output
TAACGCACTTGCGGCCCCGGGATAAAAAAAAAAAAAAAAAAAAATGGATT
NAGAGGGACGGCCGGGGGCATAAAAAAAAAAAAAAAAAAAAAGGGATTTC
NGGGTTTTAAGCAGGAGGTGTCAAAAAAAAAAAAAAAAAAAAAGGGATTT
But when I try
cat 1 | grep -w "AAAAAAAAAAAAAAAAAAAAA"
I get nothing in my output. I would like to search for exact strings in a file with more than 6 million lines.
Please comment.
Your first attempt was an exact match already. Every line you got contained the string "AAAAAAAAAAAAAAAAAAAAA".
You get nothing because you're asking for an exact word match i.e. the word "AAAAAAAAAAAAAAAAAAAAA"
Yet, there's no word as such in your example.
Let's say your looking for the word "ULTIMATE" in file 1 in a string like :
AAAAAAAAAAJJJJJJJJJJJJJDDDDDDDDDDDULTIMATEDDDDDDDDDDDDJJJJJJJ
grep ULTIMATE 1
Will give you the following output :
AAAAAAAAAAJJJJJJJJJJJJJDDDDDDDDDDDULTIMATEDDDDDDDDDDDDJJJJJJJ
While
grep -w "ULTIMATE" 1
Will give you nothing as no such word exists...
Then again if you had the following string in file 1 : AAAAAAAAAAJJJJJJJJJJJJJDDDDDDDDDDD ULTIMATE DDDDDDDDDDDDJJJJJJJ
Both
grep ULTIMATE 1
and
grep -w "ULTIMATE" 1
would give you the same output, that is :
AAAAAAAAAAJJJJJJJJJJJJJDDDDDDDDDDD ULTIMATE DDDDDDDDDDDDJJJJJJJ
You probably want
grep "[^A]AAAAAAAAAAAAAAAAAAAAA[^A]" 1
?