Usual shell command lines translated for windows

I had to work on windows recently. As a standard Unix guy, I though that

you cannot use command line on windows, you have to install cygwin, mks etc...

I was curious and I've  started to dig into cmd.exe usage. I've discovered that the windows command

line is far from being poor.

For some aspects I would even say that cmd.exe may be not less powerful than sh.

Here is a list of usual command I use translated to windows command tool.

Hope this help someone.

people crying for awk while doing scripting on windows ,  should have a closer look to "FOR /?" :-)

/bin/ls -l

dir /N /Q

grep -i \^bla myfile.txt

findstr /B /I "bla" myfile.txt

grep -v -i \^bla myfile.txt

findstr /V /B /I "bla" myfile.txt

find /tmp -name \*.c | xargs | grep blo

findstr /S blo C:\\\\tmp \*.c

find /tmp -name \*.c

dir /S /B C:\\\\tmp\\\\\*.c

echo $?

echo %ERRORLEVEL%

ls \*.c 2>/dev/null 

dir \*.c 2>NUL

pwd

echo %CD%

echo $0

echo %CMDCMDLINE%

exit 12

exit /B 12

dirname $1

%~p1

basename $1

%~nx1

which $1

%~dp$PATH:1

env | grep TERM

set TERM 2>NUL

su - foo -c command

runas /profile /user:foo command

rsh myHost -l foo command

rexec myHost -l foo command

for file in `find /tmp -name \*.txt`

do

echo `basename $file`

done

for /R C:\\\\TEMP %i in (\*.txt) DO echo %~ni

mount

net use

mount foo:/bar /mnt/bar

net use Z: \\\\foo\\bar [/USER:username /PERSISTENT:NO]

diff file1 file2

fc file1 file2

echo -n "Enter a letter : " ; read foo

set /P foo="Enter a letter : "

shutdown -g 120 -y -i 6

shutdown /r /l /f /dp:0:0


Comments:

If you really want a powerful Windows commandline, use Windows Powershell. It beats the pants off any Unix shell.

http://en.wikipedia.org/wiki/Windows_PowerShell

Posted by guest on août 09, 2007 at 05:59 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Emmanuel Jannetti blog

Search

Archives
« avril 2014
lun.mar.mer.jeu.ven.sam.dim.
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today