Showing posts with label find. Show all posts
Showing posts with label find. Show all posts

Thursday, 16 February 2012

We've been doing some code fixes lately and have had to release quite a few builds. We always have had a requirement to provide a list of all the files the build includes in the release notes. This has not really been a problem until recently as our builds consisted of an msi, so the list of files simply contained the msi file, but this has changed for a new application that we have recently started to support, I say recently in the loosest sense of the word, I believe the application has been in production since late October, but that is by the by. 

At any rate, this application does not used compiled assemblies or an msi to deploy the application, so I have had to look for a way of listing all the files and after consulting the oracle a little bit and failed to be impressed by the solutions proposed I thought I'd give the dir command a go. This is what I use, from the top directory containing the build files:
dir /B /S /A-D | find /I /V "contents.txt" > contents.txt
where
/B is used so that only file names will be listed
/S is used to go through subdirectories
/A-D is used to prevent directories from being listed

/I is used to provide case-insensitive search
/V is used to provide negative matching of the string, i.e. anything that does not contain the string, contents.txt, this is used so that contents.txt is not listed.

It works for me, so I thought I would share it here.

Saturday, 17 September 2011

grep in Windows (dos)

I sometimes wish that there was a grep command in windows, well, it turns out that there is, sort of, it's called find.

You can just pipe the output of a command to find and it will do pretty much the same as grep, e.g.
netstat -anp TCP | find  "5555"
TCP    0.0.0.0:5555          0.0.0.0:0              LISTENING
TCP    10.168.2.115:5555     10.168.2.115:39898    ESTABLISHED
TCP    10.168.2.115:39898    10.168.2.115:5555    ESTABLISHED
You can use the switch /v to get all lines that don't contain the string:
dir | find /V ".cer"
 Volume in drive C has no label.
 Volume Serial Number is B8E9-71D1

 Directory of C:\Dev\CACerts

05/09/2011  18:26    <DIR>          .
05/09/2011  18:26    <DIR>          ..
12/08/2011  18:52             3,298 tony.pfx
12/08/2011  19:19             3,274 tonytest.pfx
              2 File(s)         6,572 bytes
               2 Dir(s)   4,861,059,072 bytes free
It's possible to pipe the output multiple times. In the example below you'll see only established connections on port 5555, which may or may not be of any use but it's neat.
netstat -anp TCP | find "ESTABLISHED" | find "5555"
TCP    10.168.20.115:5555     10.168.20.115:41184    ESTABLISHED
TCP    10.168.20.115:41184    10.168.20.115:5555     ESTABLISHED
I guess you can use it as a sort of logical and capability, similarly using /V switch , you can use it as not and, e.g. for established and not in port 5555
netstat -anp TCP | find "ESTABLISHED" | find /V "5555"
 TCP    10.168.20.115:445      10.168.20.101:1974     ESTABLISHED
 TCP    10.168.20.115:3389     10.168.20.203:60815    ESTABLISHED