If you feel like learning a third shell, I find that Nushell is even easier to use than PowerShell.
open stuff.json |each { get fieldName } |where { str starts-with "asdf" } |each { $in| str upcase }
This gets all the objects in the given json file, then grabs the value of the field named “fieldName”, then filters all those values to find the ones that start with and, converts those to uppercase, and prints them to the screen as a nicely formatted list
Yeah, it does tend to be hard to determine when to use (){}[] etc.
Even after I RTFM and used those in scripts multiple times, I tend to forget it by the time I need to implement something next.
yeah you’ll have to install some helper scripts or switch to either fish or zsh. bash is nicer than bourne shell, but it is VERY basic in features by modern standards
Does it depend on some shell or shell extension? My bare bones Debian installs don’t do this. Powershell does but I’d like it on Linux too.
powershell? eww
Powershell is apparently pretty well designed. I’ve not used it myself.
one of my instructors called it “the land of the dead”
Well it does have “hell” in it’s name
You can install powershell on Linux if you’re feeling masochistic
I take PowerShell ForEach-Object any day over the unholy contraptions of awk, xargs and friends in bash.
for $variable in $(collection command); doother-command $variable;doneHm TIL, fair enough. Thanks.
But chaining still seems harder than
CommandA | ForEach-Object { DoSomethingWith $_ } | CommandBIf you feel like learning a third shell, I find that Nushell is even easier to use than PowerShell.
open stuff.json | each { get fieldName } | where { str starts-with "asdf" } | each { $in | str upcase }This gets all the objects in the given json file, then grabs the value of the field named “fieldName”, then filters all those values to find the ones that start with and, converts those to uppercase, and prints them to the screen as a nicely formatted list
You don’t need the
$in |in that last command.each { str upcase }will already pipe each item to thestr upcasecommand.Yeah, it does tend to be hard to determine when to use
(){}[]etc.Even after I RTFM and used those in scripts multiple times, I tend to forget it by the time I need to implement something next.
I think on Debian you need to install bash-completion to get bash to complete flags.
Thanks I’ll try that
yeah you’ll have to install some helper scripts or switch to either fish or zsh. bash is nicer than bourne shell, but it is VERY basic in features by modern standards
zsh does this with oh-my-zsh, as well as many other “extra” completions
ZSH still needs the completion data files to be installed. It won’t just magically know the completions.
Ah you’re right, my bad. I automatically install oh-my-zsh so I forget how much functionality is bundled into it. Edited
I don’t know the answer but does tab to autocomplete work in other contexts? E.g. you type ‘cd ca’ and it fills it to ‘cd catpics’?
I’m not at a PC right now but from memory you’d have to be in bash or similar, it won’t work in sh.
Yeah tab completion works for file paths but not command arguments