The blog is not really topic specific. I will post random stuff which I find worth sharing. Solutions to little issues, tricks etc.

Tuesday, September 9, 2008

find in Windows! Found something useful!

My Development job at Navtech, I get to develop under Windows. Yesterday, I needed to solve a standard problem, a software developer needs to do like once a week at least:

Count the lines in a text file which contain the string ""

Under linux: No Problem:
grep "<value>" file.xml | wc -l

Under windows? I fought my temptation to copy the file over to linux and to do it there. I really though, ok, what if I was a windows developer who didn't know about linux or cygwin... There should be a way!

One suggestion was to use Find & Replace and usually there is a dialog box at the end saying "Replaced 486 occurrences".

But I thought, that can't be it. I did some googling and was surprised!
Windows has a find in its good old MS DOS shell!!

C:\> find /C "<value>" file.xml

Wow, it returned the number of occurrences formatted in a weird way. But it works.
Crazy...

I should use Windows more often...

0 comments: