Live data from Hacker News

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

nushell.sh

161–170 of 215 posts

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

#161
post #91

Earlier quoted context omitted.

I think the problem with this approach is that it breaks down at some point, and then your only option is to rewrite the entire thing in a real scripting language. I.e., there is no graceful scaling path.

Isn’t this the problem with older shells as well? Eg you have to use e.g. awk or sed to deal with more complicated text processing. My understanding that the biggest difference between powershell (and nushell) and the older bash-like shells is that they deal with structured, object-like data rather than text. How would things be any different when “things break down” vs an older shell?

One of the nice things about bash is that it interacts very nicely with Perl and Ruby.

I wonder how these other shells work with the backticks and such in Perl/Ruby. Theoretically there is room for very cool interoperability but I wonder how it goes in practice and if any nice tools and patterns are being developed.

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

#162
post #120

My problem with alternative shells (anything not bash) is that I have to learn bash anyway, and if I want to use a scripting language that requires me to first install a runtime, drop into it, doesn't work on colleagues machines, etc. then there are many non-shell alternatives that are better. I'll learn nushell or whatever once a mainstream or somehow desirable distro ships with it as their default shell.

> I have to learn bash anyway

Do you? You need bash installed, certainly, but you don't need to learn bash in order to merely execute bash scripts. To use an analogy, just because your distro scripts things in Python doesn't mean one needs to learn Python to use the distro. I basically never need to write or read a bash scripts these days (I use fish, but I rarely write a real fish script either; just learn the language of your shell and YOLO).

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

#163
post #69

Earlier quoted context omitted.

I'm not really sure which other popular languages would be considered memory safe AND strongly typed. I know of both C and C++ which I wouldn't consider memory safe. And I know of Javascript, which is not strongly typed... so which do you mean?

Java, Scala, Kotlin, C#, D, Go, and TypeScript to name a few.

Even Python fits the bill.

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

#164

Earlier quoted context omitted.

Only if random-app is well-behaved (and if you knew it was you could just use `random-app ./myfile.txt`). $ echo foo > a.txt $ /proc/self/fd/0 ) $ cat a.txt bar

That's bizarre and perverse! Surely someone has brought it up as a bug before that stdin is read-write! Is there some Posix standard preventing the standard shells from opening stdin as read-only???

stdin is readonly. `<a.txt ls /proc/self/fd/0` generally gives 'lr-x------' for the permissions. The problem is that having a open file descriptor to a file lets a program get and/or act-as-if-it-had a path to the file; /proc/self/fd/ is just the easiest way to do that.

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

#166
post #151

Earlier quoted context omitted.

Only on Windows. On Linux it's the original `ls`. Same for `cat` and many other commands. That's why using `gci` / `gc` is safer if you want your script to work everywhere. https://learn.microsoft.com/en-us/powershell/scripting/whats...

Aliases can be redefined in certain situations (such as compiling a LCM configuration into a MOF for use with PowerShell DSC). The only safe way to script is to use the full command names (Verb-Noun).

Command names can be shadowed, you can `function get-content { "hello world" }` and that also breaks gc alias. The only safe way to script is to use the full command names including module names `Microsoft.PowerShell.Management\Get-Content`

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

#167
What is the general opinion about Nushell and this tools (or others)?

https://github.com/multiprocessio/dsq

https://github.com/jqnatividad/qsv

https://csvkit.readthedocs.io/en/latest

https://github.com/kellyjonbrazil/jc

https://github.com/TomWright/dasel

https://github.com/johnkerl/miller

https://stedolan.github.io/jq

https://github.com/harelba/q

...

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

#168

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…

Get-Old -Fast

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

#169

Earlier quoted context omitted.

It's cross platform. Although of you're coming from powershell background, it is easier to learn.

Powershell is also cross-platform

> Powershell is also cross-platform

I was replying to your "Microsoft based" comment. And yes, powershell is also cross platform and open source.

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

#170

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 command names, their parameters, string comparison, and regex matching are all not case sensitive, unless you want them to be.

It really gets you that you need to know aliases to keep it short? So why aren't you writing:

    du --summarize --human-readable | sort --human-numeric-sort --reverse | sed --expression='10q'

`-exec ls -lt {} +` is not good because -exec is not handled by the shell so it behaves differently to running other commands, because `+` is a nonstandard command terminator, because {} is a nonstandard placeholder and because using `find` to run commands is an onion nobody would guess.

In your terse example, `sort -h` depends on you having run `du -h` to trigger the matching "serialise information to text" and "parse information out of text" that they both need to make that one use work, because there's no separation of content and presentation (like PowerShell has) and no structured data to pass between different commands.

Not only will PowerShell tab-complete the names and the parameters, it will tab complete the properties Length and LastWriteTime because it can tell what objects come out of Get-ChildItem and what their available properties are.

> "Also, again, case-sensitive commands make me mad."

You do understand that du, find, sort, sed are case sensitive commands with case sensitive parameters, right?

Post reply on HN