3 ms·
Powershell is the first language where I managed to save time by writing a program for a task. Needless to say, I'm thrilled at the prospect of using it on Linu
by yumaikas 10y ago
Powershell is the first language where I managed to save time by writing a program for a task. Needless to say, I'm thrilled at the prospect of using it on Linux. The only thing that I hope they will need to work on is startup time making sure it performs well on low-spec servers (It can be a bit slow starting cold on older laptops).
ls -Recurse | ? { $_.Name -match ".+docx" }
- ratboy666 10y agoI am not sure what your example does. How does it differ from find . -name ".docx" ls -Recurse | ? { $_.Name -match ".+docx" } And, if these are the same, why type in twice as many characters as a command? Actually, ls -R | grep "\.docx$" is, I think, closer in spirit. Now, the issue is things further in the pipeline, I imagine. The find solution allows selection on type name, type, date, depth, mounts, properties, file system type, ownership, relative age, inode, symbolic link. find actions include delete, exec, print, quit. This can pass on needed information to further pipeline commands. However, an interactive shell is meant to allow expression of commands with a reasonable minimum of keyboarding (thus ls and not dir). I could argue that the "Unix" command should be find . -n ".docx" (because the most common -n... option used is -name). I think, to be fully reasonable the find command you want is find . -regex ".*\.docx$" which is still shorter than the PS example. I am not sure that for most interactive tasks, PS is a win. It does appear to be more elegant, but only usage over time will show if it is indeed more productive. I am looking for academic productive studies to be done, now that both bash and PS are available on common platforms.
- Analemma_ 10y agoIf you're just talking about ls/dir, then PowerShell isn't really a win. The advantages are clearer when you start talking about lots and lots of commands. A lot (but not all!) Unix tools have flags to control their output format or input filters, but that means you have to memorize different flags for all of them. OTOH, in PS you just pipe to where/sort/select and they work for everything. IMO PowerShell has better separation of concerns.
- yumaikas 10y agoI should have made it clear that this wasn't an example of Powershell being superior to bash, just what I can remember from that little script.
- jnky 10y agoIn Powershell you can also do this: ls -Recurse -Include *.docx or even this: ls -Recurse *.docx which is really quite similar your find command.