grep
Many lovers of Shela like the wonderful grep team.
Unfortunately, windows natively does not have such a command, so some set themselves up sets of various console utilities in * nix style, including grep.
For me, as an amateur to sit in the Windows console, the lack of a grep was very disturbing, so my Win scripts were always not as good as they could be. But my scripts should work on any (well, or almost any) Windows, so how to be?
Fortunately, in Windows XP (and above), there were two commands that are designed to correct the situation - this is find and a more powerful option - findstr.
the first is simple, and has a clear flaw - the text you are searching for must be enclosed in quotes. I don’t know about you, but I’m not very comfortable typing quotes every time :)
')
findstr does not require this, and also allows you to search using the power of regular expressions.
Thus, now we must remember that we are not in bash \ zsh \ etc, but in Win, and type findstr instead of grep.
Well, in my car I did the following:
echo findstr %1 %2 %3 %4 %5 > %systemroot%\grep.cmd
now it is possible without thinking about the conclusion:
C:\WINDOWS>netstat -an | grep LISTEN
C:\WINDOWS>findstr LISTEN
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING
TCP 0.0.0.0:1963 0.0.0.0:0 LISTENING
TCP 10.198.17.58:139 0.0.0.0:0 LISTENING
TCP 127.0.0.1:1025 0.0.0.0:0 LISTENING
TCP 127.0.0.1:9050 0.0.0.0:0 LISTENING
TCP 127.0.0.1:9051 0.0.0.0:0 LISTENING
TCP 192.168.56.1:139 0.0.0.0:0 LISTENING
Well, for a snack:
ifconfig:
echo IF "%1"=="-a" (ipconfig /all) ELSE (ipconfig %1) > %systemroot%\ifconfig.cmd
man:
echo %1 /?> %systemroot%\man.cmd
ls:
echo IF "%1"=="-a" (dir) ELSE (IF "%1"=="-al" (dir) ELSE (dir %1 %2 %3 %4 %5)) > %systemroot%\ls.cmd
I often give the key (s) -a (l) to the ls command on the machine, so I added their “processing”
UPD transferred to "System Administration"