Live data from Hacker News

Nushell.sh ls | where size > 10mb | sort-by modified

nushell.sh

31–40 of 215 posts

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#32

Earlier quoted context omitted.

- Better errors - Native support for JSON, etc (no more ConvertFrom-* ConvertTo-*) - Less verbose - Different visualisation

PowerShell isn’t that verbose, compared to NuShell. The ls example would be (with standard PowerShell aliases): gci | where { $_.Length -gt (10 * 1024 * 1024) } | sort LastWriteTime -gt might seem weird, but it’s better than overloading >. (Also, I like the fact that PowerShell is built into Windows and has a large corporation behind it.)

The fact PowerShell has this masochistic tendency to have commands that start with capital case already makes it outside of the realm of consideration for me. It's absolute nonsense. Also I have to say your example is extremely confusing and would probably take quite a bit of time to write IRL. For reference, the equivalent in sh would be:

   find . -maxdepth 1 -type f -size +10M -exec ls -lt {} +
Or a very terse example:

    du -s -h * | sort -r -h | sed 10q
The thing is that if you're already used to POSIX-compliant shells then this is simply natural to write. Nushell has a different proposition of making it closer to natural language, which makes the learning curve much better. PowerShell just makes it different, but not really that much better.

Also this is somewhat tangential, but I hate that PowerShell 5 and 7 are completely different things, and that PowerShell 5 is still the default even in Windows 11.

Oh yeah, and just for lols this is the same thing in zsh:

   ls -lt *(.L+10240k)
By the way, I should note that it's possible to make the PowerShell example much simpler like the following:

   gci | ? Length -gt 10MB | sort LastWriteTime
The thing that really gets me here is the need to know aliases to keep it short, if you were to do it without the aliases it would look like this:

   Get-ChildItem | Where-Object { $_.Length -gt 10MB } | Sort-Object LastWriteTime
Also, again, case-sensitive commands make me mad.

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#33
post #23

Earlier quoted context omitted.

Sorry but that looks terrible.

What about it looks terrible? The braces are necessary, because this is a lambda.

I'd say that $_ is really weird and looks horrible. Also having to do (10 * 1024 * 1024) instead of just writing 10MB is a downgrade even compared to POSIX-compliant sh. In my other comment I've added a few examples in sh, zsh, and a better PowerShell example:

   gci | ? Length -gt 10MB | sort LastWriteTime

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#34
post #5

What's the advantage of this over PowerShell?

Recycling my comment from last time this came up. Some reasons I prefer Nushell over PowerShell:

- less verbose syntax

- better cross-platform support (PowerShell is technically cross-platform, but it has some baggage from its Windows-first history)

- way faster to start up

I'm biased (I'm a member of the Nushell core team), but those are all things that drew me to start contributing to Nushell.

On the other hand, Nushell is certainly less mature+stable than PowerShell. And if Windows administration is your main use case, PowerShell can't really be beat.

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#36
post #16

So, '>' isn't for redirection anymore. How does one do that? open foo.txt | append "world"| save --raw foo.txt Oh.

This reminds me of how Fish handles process substitution without requiring a special syntax. I love it! It may seem a bit odd or even cumbersome to experienced shell programmers, but in my experience with Fish, this kind of thing helps a lot with ease of learning.

It is much much better to have things be actual commands (which have a uniform syntax, and are `--help`able) rather than obscure sigils like $(#!@$).

Fish is amazing!

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#37

So, '>' isn't for redirection anymore. How does one do that? open foo.txt | append "world"| save --raw foo.txt Oh.

Historically we would discourage shell users from cat somefile.txt | whatever and instead tell them to use either whatever or, if the command accepts input file names as arguments then use those like whatever somefile.txt or whatever -i somefile.txt etc But perhaps in fish, “useless use of cat” is not so useless and would be recommended? (I mean aside from the fact that they seem to recommend their “open” command, an…

For some reason I never liked to do it the "right way". First of all it doesn't seem to actually matter.

But most of all the cat way just aligns with my mental model more. Data flows left to right, if you catch my drift.

It also makes it easier to add arguments to the end if re-running it.

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#40

Earlier quoted context omitted.

PowerShell isn’t that verbose, compared to NuShell. The ls example would be (with standard PowerShell aliases): gci | where { $_.Length -gt (10 * 1024 * 1024) } | sort LastWriteTime -gt might seem weird, but it’s better than overloading >. (Also, I like the fact that PowerShell is built into Windows and has a large corporation behind it.)

The fact PowerShell has this masochistic tendency to have commands that start with capital case already makes it outside of the realm of consideration for me. It's absolute nonsense. Also I have to say your example is extremely confusing and would probably take quite a bit of time to write IRL. For reference, the equivalent in sh would be: find . -maxdepth 1 -type f -size +10M -exec ls -lt {} + Or a very terse exampl…

PowerShell isn’t case sensitive. Personally I prefer `where` over `?` though.
Post reply on HN