7 ms·
So basically instead of doing dir C:\ I have to learn to type List-Directory-With-Files Drive=C Folder=/ (made up example, but you get the point)
by pawadu 10y ago
So basically instead of doing
dir C:\
I have to learn to type
List-Directory-With-Files Drive=C Folder=/
(made up example, but you get the point)
- Tarean 10y agoNo, dir `c:\ works` just fine. It is a short version for Get-ChildItem -Directory C:/
- Senji 10y agols c:\ or gci c:\
- taspeotis 10y agohttp://imgur.com/kDQVBZw http://imgur.com/kDQVBZw
- pawadu 10y agoSure, go ahead, ruin my joke :) More seriously, how many seconds did it took for the PS to answer to that command?
- taspeotis 10y agoMeasure-Command {dir C:\} TotalMilliseconds : 2.9708 Measure-Command {Get-ChildItem "C:\"} TotalMilliseconds : 2.4161
- pritambaral 10y agoCompare it with cmd.exe's dir
- taspeotis 10y agoI have had a quick look through here [1] and most of the answers involve timing precision of two significant digits. By that metric, PowerShell's 2.4ms clocks in at 0.00 seconds. Which means cmd.exe (at a precision of two significant digits) can't beat it. [1] http://stackoverflow.com/questions/673523/how-to-measure-execution-time-of-command-in-windows-command-line http://stackoverflow.com/questions/673523/how-to-measure-exe...
- Arnavion 10y ago"2.4" or "0.0024" or "24000" all have two significant digits. Leading and trailing zeros don't count as significant digits.
- taspeotis 10y agoMy mistake, you are right [1]. Thanks for the correction. [1] https://en.m.wikipedia.org/wiki/Significant_figures https://en.m.wikipedia.org/wiki/Significant_figures
- Already__Taken 10y agoc:\temp>timecmd dir c:\ Volume in drive C is Windows Volume Serial Number is A0A8-6684 Directory of c:\ 01/11/2016 12:45 <DIR> AMD ... 17/11/2016 12:52 <DIR> Windows 9 File(s) 25,337 bytes 18 Dir(s) 71,423,356,928 bytes free command took 0:0:0.08 (0.08s total) bat from http://stackoverflow.com/a/6209392 http://stackoverflow.com/a/6209392
- jodrellblank 10y agoand find that command prompt dir is faster because it's doing less, because it's less capable. It's not creating System.IO.FileInfo and DirectoryInfo objects for each thing in the directory.
- 0xfeba 10y agoSecond time the HD has probably cached the result...
- snuxoll 10y agoMeasure-Command { gci C:\ } TotalMilliseconds : 1.3334 It's pretty fast
- jeeva 10y agoI feel like I should point out that `Measure-Command {dir C:\}` is just aliasing gci. PS> Measure-Command {Start-Process cmd -ArgumentList '/c dir c:\'} TotalMilliseconds : 14.0138 PS> Measure-Command {gci C:\} TotalMilliseconds : 10.7484 Second run on each of those went down to closer to 40% of each, yay caching. Of course, the start-process is possibly taking up a chunk of time, there. With no measure-command for cmd, it makes it a little harder to gauge.
- bhouston 10y agoBoth DIR and LS do list directories in PowerShell. But all parameters on DIR and LS seem to result in errors, even "dir /h", "dir /?", "dir -h", "dir --help", etc. That is a bit annoying.
- erk__ 10y agohelp( / man / Get-help) dir brings up the help menu for Get-ChildItem
- sapphire_tomb 10y agoDIR and LS are both aliases for Get-ChildItem, which doesn't support the flags you're after.
- kuschku 10y agoThen don't make them aliases, if they're not the same. The issue already happened with cURL.
- eriknstr 10y agoThey are aliases for Get-Children. Just like you can have an arbitrary alias for anything on UNIX. If I so pleased I could make an alias so that when I wanted to delete a file I'd type emacs some-old-file-i-dont-want.c Emacs would be an alias for rm on my system. That being said I think it was quite offensive of MS to use wget and curl as aliases, even though they may have had no ill intentions. I'm ok with using ls and echo and names of other such basic commands as aliases, but with tools like wget and curl that are known for their vast array of useful features you either implement their features and options or you don't use their names.
- kuschku 10y ago> I'm ok with using ls and echo and names of other such basic commands as aliases, but with tools like wget and curl that are known for their vast array of useful features Well, I can't do my typical ls -la either.
- douche 10y agoAt least Powershell has Unixy aliases for the common commands. I don't know how many times I've been in a cmd shell and typed ls and then swore at things.
- cableshaft 10y agoI just wrote batch files that serve as aliases for those. I type ls in my command shell and it does a dir /w behind the scenes, which makes it look more like how it looks in Linux anyway. Here are the ones I have: * cat.bat: type %1 * clear.bat: cls * diff.bat: fc /n /w %1 %2 * ls.bat: dir /w %1% * pwd.bat: cd * touch.bat: echo . >> %1 * top.bat: tasklist All have an @echo off at the top too. Touch is a little janky, because I couldn't figure out how to actually create an empty file with nothing in it from the command prompt. I'm actually not really a Linux person, but on Mac you kinda have to use these, so I got more used to using them than the Windows counterparts.
- Senji 10y agoYou could put the @ in front of the command like so: 1 line file: @type %1
- ygra 10y agocopy nul %1 >nul to get an empty file. It's not a replacement for touch, though, as touch will do something different to existing files. Your attempt will silently overwrite the file in that case.
- jeeva 10y agoCouldn't you just append null to a given filepath to get the same result, or am I misguidedly assuming that >> creates files that don't exist?
- ygra 10y agoInteresting idea, but type nul >> file doesn't change the metadata, perhaps because nothing was written. But yes, it would at least not destroy files.
- kierenj 10y agoNope - what makes you think that?
- UK-AL 10y agofirst command works perfectly fine under powershell.
- cm2187 10y agoBeing verbose would be a good thing (more readable than a cryptic acronym) if there was auto-complete support. A console should really be a small IDE that gives live feedback on what arguments are possible in the current context, etc. But that's not the way powershell was designed.
- captainmuon 10y agoThere is auto-complete support. I just tested it (not a powershell user myself), and it seems pretty intelligent. For example, if you type dir | sort <TAB> it suggests Attributes, BaseName, CreationTime, .... All properties of file objects (which is what dir returns). Also there is PowerShell ISE, which is a IDE for powershell, but I haven't really tried it yet.
- cm2187 10y agoThat's not what I mean by autocomplete. What I mean is more like Visual Studio's intellisense, ie a drop down that lets you know what are all the options from there. You can type DIR <TAB>, that won't tell you that you can apply the parameters "/p" or "/w" nor what these parameters mean. ISE does a slightly better job but is based on a static specs, rather than the current state of the system. So it won't list the VM names currently active in the system for instance. Yes you can type -?, but that's as bad as having to go on the web to read the documentation. It's disruptive. The point of a good auto-complete is to have a list at your fingertips with a short description of what it does, without interrupting your train of thought.
- Already__Taken 10y agoThe ise can do that if you've got the object at the time you're writing like that, it can't run a command for you as your typing it. You'll never get a drop down list in the host terminal windows has it doesn't have a GUI layer like that. Wrap it in a electron app and make one. you can type `dir -<tab>` and cycle through the options. type `get-help dir` to see what they do or install posh-git and use `dir -<ctrl-space>` to get a menu of options to choose. I didn't know about -?
- benaadams 10y agoAdd posh-HumpCompletion https://github.com/stuartleeks/posh-HumpCompletion https://github.com/stuartleeks/posh-HumpCompletion then you just need to type first Caps and hit tab
- chokolad 10y agoYou can do the same thing with PSReadline, which is included in Win 10 installs.