Search for specifc words in huge log files or txt files
So you have a text/log file which is about 200MB? 800MB? 1GB? 2GB? Ok the data is in there, but how you gonna search for what you want? Now what if I have about 100 files 2GB each? Oops…
This is a must know, coz you may never know when you will need this.
Say I have about 300 log files named u_1000.log, u_1001.log, u_1002.log …. u_1300.log and I need to find out all entries which has the text “Ratish” in it.
- Open cmd
- Navigate to the location of the log file
Type the command:
type u*.log |find /i “word to search” >> c:\temp\output.txt
type – This is a part of the command and I am not asking you to “Type”
u*.log – You need to specify if the log file is *.log or *.txt. u*.log is the name of the log file sequence like shown above. If you specify u*.log, it will search for the keyword in all files starting with alphabet ‘u’ residing in the location specified.
“word to search” is the word you are searching in the logs. In this case Ratish
When this command is completed, you will get a txt file with the contents in the log file with the “word” you searched for.
Note: 1. At the start of the command there is a type and this should be included while running this.
2. The command prompt should be navigated to the location where the log files reside.
3. Most imp – RUN AS ADMINISTRATOR (dont ask me why… lol)
Keywords: Search for a text in a txt file, search huge text file, search huge log files, query huge logfiles, search for a name in a txt file, searching text files, parsing txt or log files