Search for text in files

By | February 9, 2011

Search for text in files

How to Search for text in files? Some time we require to find a files that contain specific text, search files for text is necessary if you have a multiple files and you want to find text in files, let say you have various log files and you want to know which file having error, that time you can use below command


Command to Search for text in files

for /f "tokens=1" %a in ('dir /b *.log') do find /n "Access is denied" >>c:tempresult.txt

I have used this command in many scenarios, like we run a script for all the users and script will generate a log file for each user and we have to verify each log files for errors, we can’t check all files manually, and that time we have used this procedure to search text files, check the result.txt file for the output.

Note: Run this command from where the log file there

Related Articles

Check the server IP address from multiple servers

How to check the DNS zone status from the list of servers

More useful commands

Leave a Reply

Your email address will not be published. Required fields are marked *