The following lists some of my favorite Unix commands and maps the associated PowerShell and DOS commands, if any. If there is one Unix command I would love to have in PowerShell, it is the grep command with its regular expression support. I have noticed significant improvement in Vista's search capabilities compared to earlier versions of Microsoft operating systems that I have used and I would love to see that harnessed in PowerShell so that I could use it from the command line. The table appears a ways down, so scroll down to it.
UPDATE (24 March 2008): Note that I have updated this table with information on a grep
equivalent and on the availability of less
as an extension. Thanks to Kirk Munro for pointing both of these out (see Comments) and to Jeffrey Snover for his write-up of Select-String
at http://blogs.msdn.com/powershell/archive/2008/03/23/select-string-and-grep.aspx.
Thanks also to Marco Shaw for pointing out that start-transcript (which can be closed with stop-transcript) provides functionality like Unix's script command. Thanks to Jonathan for mentioning tasklist as an alternative to ps and mentioning F7 for a graphical presentation of history commands.
Unix/Linux | PowerShell | Windows Vista DOS |
---|
ls | ls dir | dir |
cp | cp copy | copy |
mv | mv move | move |
rm | rm del | del |
netstat | netstat | netstat |
man | man help | help |
ps | ps tasklist | tasklist |
finger | finger | finger |
script (stop with CTRL-D) | start-transcript (stop with stop-transcript) | |
clear | clear cls | cls |
cat | cat type | type |
history / h | history / h F7 | F7 |
unzip | unzip | unzip |
zip | zip | zip |
tee | tee | |
grep | Select-String | |
more | more | more |
less | less (extension) | |
edit | edit | edit |
kill | kill taskkill | taskkill |
Type ‘man
’ without any options in PowerShell command-line
to see long list of supported commands and scripting keywords.
The Windows PowerShell Quick Reference and Getting Started with Windows PowerShell are also useful resources.
7 comments:
Hi Dustin,
Check out the post on the PowerShell Team blog, here:
http://blogs.msdn.com/powershell/archive/2008/03/23/select-string-and-grep.aspx.
Jeffrey Snover points out how Select-String is used as the PowerShell equivalent of grep (and how there should be an alias linking grep to Select-String in PowerShell).
Also if you install the PowerShell Community Extensions (http://www.codeplex.com/PowerShellCX), you'll get less.exe installed and ready for use in PowerShell as well.
The only one I'm not sure about in your list is script.
Hope this helps.
Kirk Munro [MVP]
Poshoholic
http://www.poshoholic.com
Kirk,
Thanks for pointing out the grep equivalent and the availability of less. I'll definitely be looking into both. I appreciate you writing the comment up to let me know and to make this blog entry more complete.
Dustin
script -> PSH: start-transcript
tasklist is the CMD equivalent of ps, and F7 displays CMD's command history.
Thanks, Marco and Jonathan. I have added the information you provided to the table above.
Dustin
For start-transcript check this also - http://dmitrysotnikov.wordpress.com/2008/02/21/make-powershell-record-everything-you-do/
Shouldn't gci be listed as a PS equivelant/like for ls as well?
Post a Comment