I am not an expert with linux, but following various posts on this forum, I have been trying to write a script to match pattern of charters occurring together in a file.
My file has approximately 200 million characters (upper and lower case), with about 50 characters per line. I have merged all the lines together to make it one line using
tr -d '\n' < input.txt > oneLineInput.txt
I now have all charcters in my file in the same line without spaces.
I am trying to count the number of times the specific characters occur together. For example, in the file below
IamTryingtobuildascriptfortrestingthetyposinmysentence
I am trying to look for the pattern 'tr' that occurs in the sentence. The script I have now is
grep -o -i oneLineInput.txt -e tr | sort | uniq -c
The above script works perfectly fine for a small file, but when I try to run it on my actual file with more than 200 million characters, it takes ages to finish the task (I lost patience and did not check the total time taken).
Is there a way I can optimize the code?
Next, I have been trying to get the position of the match. For example, in the above example file, 'tr' is starts on 4th and 27th position. I just want the number as output.
Is it possible?
Thank you 