Skip to main content

Batch file search for text and count lines

Hi all,
I had just finish a batch file which will search for certain string in a file then count the number of lines with the string. Its great for searching through logfile.

Points to take note:
Remember to put Logfile.txt and countData.bat in the same folder.
%1 is actually the value that the user can pass in.
Logfile.txt is the file that you are searching in.

There is 2 ways to get the batch file to work. One is type countData.bat "stringThatYouWantToSearch" in the command prompt.

Second is create another batch file and type countData.bat "stringThatYouWantToSearch" in that batch file. Then double click on it to run it.

Click Here for the Code with Megaupload

or just copy the code below and paste it into a text file and rename it into countData.bat

del sorted01.txt
del count.txt

type Logfile.txt| findstr /I/C:%1 >> sorted01.txt

find /v /c "hahaharandomword" sorted01.txt >> count.txt

echo -------------------------------------------- >> count.txt

del sorted01.txt

Comments

Popular posts from this blog

Today's Forex Focus, 30 Jan 2024

 Ah, nephew, let's dive into the Forex market today, shall we? It's like peering into a crystal ball, but with a bit more logic and a lot less mysticism. First up, we've got the EUR/USD pair showing a bit of a bearish tilt. The dollar's holding steady like a rock in a stream, buoyed by investors who've got their eyes glued to the upcoming Federal Reserve policy meeting. There's a bit of a buzz about geopolitical tensions in the Middle East, making investors a bit jittery and giving the dollar a bit of a boost​​. Then, there's talk about the Federal Reserve potentially pushing back against the idea of a rate cut anytime soon. This is like a plot twist in a thriller movie for the traders, who are now less convinced about a rate drop in March. The dollar, meanwhile, is flexing its muscles a bit, up by 0.19% against a basket of currencies. Across the pond, the Euro's taken a bit of a tumble, and there's chatter about when the European Central Bank might ...

Free server for Terraria: Singapore Base

Update: Click here for the latest update IP: 175.156.159.250 port: 7777 password: server672011 email: ohguowei@gmail.com updated: hai, i give up on port forwarding. sorry guys, i will be using hamachi for terraria. this game is just too unstable for multi player hamachi ip: 5.100.228.220 hamachi network: sgterraria hamachi password: sgterraria terraria password: server672011 opening time 12pm to 12am. email me if you need help, but dont expect me to do much since this is a free server.

My thought on Gold fundamental analysis 22 April 2014

Gold broke the 1280USD barrier dragging the bunch of precious metal with it, seem that it will be going down for awhile as the US economic strengthen ( student loan issue? ). Maybe time to get some platinum ?