Old good command line #3

Continue our series (Post #0, Post #1, Post #2)

  • findstr. Another déjà vu? Almost. The command is really similar to “find” which was described in issue two of “Old good command line”, but it is much more powerful. It is even more powerful than grep. Really. It has several options for output (line number in file before line, file name only, character offset, etc.), input (file list from a file/console, search strings from file/console…) and search (search literally, any of the words or the whole string and even regular expressions). It really can do much good in case you need do some quick search in text files or in output of another program, or if you need automate some easy search task without excessive coding or installing PoSh or Perl where they are not present. In the cases above it is your choice. Let us see some simple examples of usage. At the moment I have three .txt files in a folder.

image

notice the difference between the files: file2.txt has 45% instead of 40 and file3.txt has a space in the beginning of the second line. Let us search for word “done”:

image

simple enough, isn’t it? Let us get some more information:

image

this command showed us which file has word “done” in which line (2) and with which offset (14). Notice that the offset counts towards the line, not the word. Now let us find file where “45” stands in the very beginning of the line:

image 

or another way:

image

Easy, still powerful.

  • msdt. The command actually starts some GUI program, so it is not exactly a CLI command. But still it has several options in command line and is interesting enough if you need to tell a user which troubleshooting wizard to run or just need a list of wizards =) For example the command

image

opens the window

image

and I can get recommendations on my notebook’s power consumption. Actually, you can even create your own troubleshooting packs, it you can get through this: http://msdn.microsoft.com/en-us/library/dd323774(v=VS.85).aspx. I’m going to try creating one in future Smile

  • openfiles. If you need to get a quick view of files open via network (or locally, but it requires some work) and may be put it in a file or process it somehow automatically, then it is your choice. This screen

image

is actually identical to this one:

image

and as you can close the session in the latter case

image

you can do it in the first. But in case you have many, really many files open, the CLI option is, perhaps more viable, because it allows you to do the following:

image

As you can see, we queried opened files and filtered them to what we need to get with “findstr” (hey, my article is handy at least for me – look above Winking smile ). Then we got ID of the session in which our file is open and put it down with the “/disconnect” option. If we have several thousand sessions then it will be handier than GUI.

That will complete the article, enjoy.

Advertisements

4 thoughts on “Old good command line #3

  1. Pingback: TextAnalysisTool.NET | IT, IS, etc...

  2. Pingback: TextAnalysisTool.NET » IT, IS, etc…

  3. Pingback: IT, IS, etc… » Blog Archive » Creating your own troubleshooting pack

  4. Pingback: Собственный troubleshooting pack » ИТ, ИБ и т.п.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s