Bash has a huge number of little shortcuts that are difficult to learn. When one encounters a sequence of symbols like $(...), it is difficult to Google for its meaning. The reason shells nevertheless have these shortcuts is of course because they are shells: from the commandline it can be very convenient to use shortcuts. But, in my opinion, that's where it should stop: one shouldn't use a shell language for scripti…
Things I Wish I'd Known About Bash
181–190 of 272 posts
Re: Things I Wish I'd Known About Bash
#182What is the best alternatives to bash for writing fairly large automation scripts? I have already looked at Python, Lua and Guile. The last two especially since I like using them and they have some sort of posix interfaces. I haven't looked at Perl 6.
Re: Things I Wish I'd Known About Bash
#183Hang out in #bash on IRC Freenode and you will be a Bash jedi http://mywiki.wooledge.org/BashFAQ best resource IMO for quick Bash syntax lookups as I always need to refer to the BashFaq to remember parameter expansion sub-string retrieval. parameter result ----------- ------------------------------ $name polish.ostrich.racing.champion ${name#*.} ostrich.racing.champion ${name##*.} champion ${name%%.*} polish ${name%.…
They are needlessly rude and mean at #bash. A bunch of scumbags, actually.
Re: Things I Wish I'd Known About Bash
#184Earlier quoted context omitted.
Would you consider non-trivial install scripts as an exception to this general rule? I mean, you wouldn't write some install script in ruby or python, right?
I don't know why not? At the least, rather than Bash, you might consider Perl as a default, lowest common denominator for scripts that need to run anywhere. - It's nearly as ubiquitous as bash. - It has approximately the same kinds of file/path operations built in. - It has reasonably good support for strings/regexes/etc. all built-in, so you don't have to call out to tools like sed/awk/grep all the time and hope tha…
Perl regexes are the best of breed that everyone else replicates — far better than “reasonably good.”
The Perl erasure in this HN thread is startling.
Re: Things I Wish I'd Known About Bash
#185Re: Things I Wish I'd Known About Bash
#186Earlier quoted context omitted.
Which is why the parent advised to treat the man page like a reference document, by searching in it. Some man pages are just badly written and are indigestible even when searching for a specific thing, but in general, that approach works quite often.
Is there some trick to searching man pages that I don’t know? Because my usual experience is: type man foo type /-p type n n n n n n n n n as there are a bunch of matches like “...does bar when combined with -p...” A presentation of man pages that used hypertext would make me a lot happier.
-p
Potrzebie mode ...
So search for it, e.g., /^ *-p
The caret regex anchor matches at the beginning of line, and the Kleene star matches zero or more of the previous pattern. In English, the above pattern reads “match -p only when it occurs as the first nonblank characters on the line.”The surrounding context may be different, so adapt your search pattern accordingly.
Re: Things I Wish I'd Known About Bash
#187Earlier quoted context omitted.
Yeah, but why are you trying to use a search engine that cares less and less about exact matches, when there's a manual? >man bash /\$\( # search pattern needs escaping ... value is evaluated as an arithmetic expression even if the $((...)) expansion is not used (see Arithmetic Expansion below). Word split‐ ... n # go to next match Command Substitution Command substitution allows the output of a command to replace th…
Man pages are specifically reference documents, not tutorials or guidebooks. To say one should use a man page is to say that one must completely digest the entirety of the tool prior to ever actually using it. That’s just simply not feasible, nor should it be expected of anyone beyond trivial tools. Man pages simply don’t provide the context for solving a problem like a guidebook or tutorial would, which is why there…
Re: Things I Wish I'd Known About Bash
#188Earlier quoted context omitted.
If foo has a Texinfo manual (GNU tools like bash usually do) then you can try `info foo` and search the index with i or I for -p. Texinfo manuals also have hyperlinks you can press enter on. info is a greatly underused system and I'd recommend any *nix users to spend some time learning how to navigate it.
Thanks. Is there a good way to open that in a browser, rather than a console?
Re: Things I Wish I'd Known About Bash
#189Earlier quoted context omitted.
In general, the best way to read Info documentation is inside Emacs.
"If you are a bash newbie, you should read the bash manual. If you want proper search for the manual, you should use info. If you want proper use of info, you should use Emacs." Kind of a deep rabbit hole, isn't it?