Friday, August 10, 2007

Usual shell command lines translated for windows.

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

No comments: