Thursday, October 23, 2014

Filtering log files on Windows 7

Note: this is just a reminder about Windows analogues of grep - find and findstr.

Being inspired by this article: http://habrahabr.ru/post/71568/
now leaving some how-to's when working with large log files, containing messages from many processes.

How to get all messages from a process with PID=8238

C:\logs> type file.log | find "8238"
2014-09-19 16:40:22 8238   [INFO] Closing Session
2014-09-20 16:40:22 8238   [INFO] Closing Session
2014-09-22 16:40:35 8238   [WARNING] Error: No IC output on selected net (i.e., no driver).Stopping.
2014-09-22 16:40:50 8238   [INFO] Close Session: Design file: demo2.p

2014-09-22 16:41:38 8238   [INFO] Close Session: Design file: demo2.p
2014-09-26 15:45:11 8238   [INFO] Close Session: Design file: demodiff.p


How to get messages from interval [2014-09-22, 2014-09-26]

C:\logs> type file.log  | findstr /r /C:"2014-09-2[2-6]"
2014-09-22 16:40:22    [INFO] Closing Session: 
2014-09-22 16:40:35    [WARNING] Error: No IC output on selected net (i.e., no driver).Stopping.
2014-09-22 16:40:50    [INFO] Close Session: Design file: demo2.p

2014-09-22 16:41:38    [INFO] Close Session: Design file: demo2.p
2014-09-26 15:45:11    [INFO] Close Session: Design file: demodiff.p


Note that  /r stands for regular expressions. But regexps are limited in findstr, only [class] or [a-b] is allowed. See http://technet.microsoft.com/ru-ru/library/bb490907.aspx for reference.

Thursday, October 2, 2014

Compiling .cpp files in FAR by pressing Enter

Sometimes we write small prototype console applications to test any functions or learn C++ features. It would be nice just to edit .cpp file and get .exe compiled at once, like Linux guys can do just by entering gcc command.



What you have to do - just to mimic
Start->All-Programs->Microsoft Visual Studio 2008->Visual Studio Tools->Visual Studio 2008 Command Prompt, which simply calls
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"" x86