6 ms·
It’s amazing how much of a superpower merely reading the manual is nowadays. <https://www.gnu.org/software/bash/manual/bash.html#Arrays https://www.gnu.org/sof
by teddyh 2y ago
It’s amazing how much of a superpower merely reading the manual is nowadays.
<https://www.gnu.org/software/bash/manual/bash.html#Arrays https://www.gnu.org/software/bash/manual/bash.html#Arrays>
- latexr 2y agoWhile I agree with the larger sentiment I think you’re making (I also make it a habit to peruse the manual just to see what is available), how often do you reread the manual, especially for your shell? I knew about associative arrays in bash, but not by reading the manual as those were introduced in v4 and I’ve been using bash for longer than that.
- teddyh 2y agoYou should probably read the release notes for new major versions. Also, anytime you think “I wish there was <feature> available in this program”, you should probably double-check if such a feature has appeared since you last learned the program.
- dredmorbius 2y agoThat's how I discovered the '&' regex feature in less some years back.
- teddyh 2y agoDo you mean PCRE’s “(?&name)” feature? That is not portable; for instance, Python calls it “(?P=name)”. Or do you mean the common feature of “&” in the replacement string meaning “the whole matched string”? While this feature is common in languages which use regexps (including ed, sed, awk, etc.), that’s not actually a regexp feature, since the & character has that effect in the replacement string, not in the regular expression. It is also not always portable; for instance, Emacs requires escaping as \& for the character to have the special feature.
- dredmorbius 2y agoFrom man(1) less: &pattern Display only lines which match the pattern; lines which do not match the pattern are not displayed. If pattern is empty (if you type & immediately followed by ENTER), any filtering is turned off, and all lines are displayed. While filtering is in effect, an ampersand is displayed at the beginning of the prompt, as a reminder that some lines in the file may be hidden. $ less --version less 487 (GNU regular expressions) Copyright (C) 1984-2016 Mark Nudelman
- teddyh 2y agoOh, you meant the program “less”! Right, I understand what you meant now.
- dredmorbius 2y ago:-) Yeah. I was viewing some files and thinking "it'd be really cool if less(1) had some way of filtering to just lines matching a specific pattern". RTFM'd and TIL'd. Mind that at that point I'd used less for ... oh, at least 30 years.
- sgarland 2y agoAgreed. This is also how I found out that features in Python I took for granted, like breakpoint(), were much more recent than I thought (3.7). Nothing like having to use ancient versions of a language to discover limitations.
- akvadrako 2y agoI do a fair bit of bash scripting and there is no way I can remember all the features and syntax I use, so of course I read parts of the manual regularly and often learn new things. You don't need to ever read the whole thing.
- sgarland 2y agoI once worked with a dev (frontend, of all things) who reread the bash manual annually. I work in ops, and I don’t even have that dedication. My hat is off to them.
- dredmorbius 2y agoTBF, the Bash manpage now runs > 80 pages: man -Tps bash | ps2pdf - bash.pdf That can be daunting. Though illuminating.
- deleted 2y ago[deleted]
- wruza 2y agoMy one-shot memory worsened with years but grasping concepts from examples got much better due to experience. So I find walls of text much less useful than a continuous “synopsis” of snippets and best practices. One usage example is worth a hundred of words and few pages of it may be worth a whole manual, especially when “at hand” through editor means. For bash idk if that exists on the internet, so I maintain my own in my one big text file. I wish every manual had the synopsis-only section (maybe I should just LLM these).
- farrelle25 2y ago> One usage example is worth a hundred words ... For bash idk if that exists on the internet, ... Totally agree with that - I maintain a big txt file too. Maybe this bash compendium is a bit similar: https://www.commandlinefu.com/commands/browse https://www.commandlinefu.com/commands/browse
- teddyh 2y agoYou might like these: • <https://learnxinyminutes.com/ https://learnxinyminutes.com/> And some code search engines: • Debian: <https://codesearch.debian.net/ https://codesearch.debian.net/> • Python: <https://www.programcreek.com/python/ https://www.programcreek.com/python/> • Linux: <https://livegrep.com/search/linux https://livegrep.com/search/linux> • GitHub: <https://grep.app/ https://grep.app/> • HTML, JS and CSS: <https://publicwww.com/ https://publicwww.com/>
- johannes1234321 2y agoBash is low on the list of things to learn, especially as many greybeards suggest keeping on POSIX compatibility and/or using a "proper" language (Python, older: Perl) for anything longer than a few lines.
- jeltz 2y agoThey suggest that based on their experience. Error handling in bash is awful so I advice against using it for anything complex.
- irunmyownemail 2y agoAnything complex should be written in a competent language like Java. Script languages (like Bash and Python) are for short (a few lines long) scripts. Using the tool outside the scope of what it was designed for is not a good idea.
- teddyh 2y agoTell me you have never seriously used Python without telling me you have never seriously used Python. I mean, viewing Python strictly as a scripting language? I am honestly lost for words. There are many huge and major applications and web sites written in Python, without people regretting it after the fact. And yet here you are dismissing it out of hand without a single argument.
- Izkata 2y agoMeanwhile most of the time topics like this come up and people hate on shell scripts, those of us that like them see those criticisms the same way you're looking at this comment about python: So far out there it's almost not worth responding. I think that's why GGP and GGGP think "greybeards" don't think it's worthwhile based on experience - it's actually not worth arguing against misinformed comments so newer people don't realize it's still heavily used, just quietly in the background for things it's actually good at. Further down is a comment about that: https://news.ycombinator.com/item?id=42664939 https://news.ycombinator.com/item?id=42664939