2012-06-20

grep in windows

Yesterday I grew tired of browsing through a log file in windows, you know having it open in Notepad++, then when it's updated, you reload it and go to the last line and search "upwards" to see the last entries.

After looking through some help files for command line I realized that it's possible to chain commands in windows, just as it is in UNIX-style operative systems.

following little neat items is hence something I use constantly
cd \tools\wamp32_bit\logs
type apache_error.log | findstr "time:"


Now, when I looked at the findstr help, it seemed as if I could use regular expressions in conjunction with it, and yes, you can, kinda.... The only issue is that it doesn't really allow many options that you would like to have. Say that I in the above search option would like to find any rows where the time is "bigger than 100ms(time:201.1010)". In a normal regex-world, I'd do something like findstr "time:[0-9]{3,}". This however, doesn't work in the regular expression matcher found in "findstr".

Well... I guess there are some advantages for using a non-windows OS after all :-\

*edit:
Also, if you want to have a larger command prompt window. There is the option of editing this in the command prompt window by "RMB on window border"\Properties\layout

and then change the screen buffer size (I use 235:500)

Inga kommentarer:

Skicka en kommentar