Timeline for Why is using a shell loop to process text considered bad practice?
Current License: CC BY-SA 4.0
17 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| S Jun 8, 2021 at 16:21 | history | suggested | ᄂ ᄀ | CC BY-SA 4.0 | Proper English |
| Jun 8, 2021 at 15:54 | review | Suggested edits | |||
| S Jun 8, 2021 at 16:21 | |||||
| Feb 12, 2018 at 14:01 | comment | added | F. Hauri - Give Up GitHub | @StéphaneChazelas I'm proudly to present my newConnector function, for reducing forks, present on github | |
| May 23, 2017 at 12:39 | history | edited | CommunityBot | replaced http://stackoverflow.com/ with https://stackoverflow.com/ | |
| Apr 13, 2017 at 12:36 | history | edited | CommunityBot | replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/ | |
| Dec 1, 2016 at 17:51 | comment | added | Tensibai | @Stephane well, Cisco nexus does use bash, checkpoint, f5, beware, bluecoat also (what I call embedded systems indeed) I was scoping distribution on Linux, but I hardly remember a hp/ux or Aix without bash, even the Aix emulation within os400 I've seen ad it. But anyway, the point was more 'there's a better chance to get bash than perl', I fully agree that staying posix compatible should be the main goal when you write 'portable' code. | |
| Dec 1, 2016 at 16:56 | comment | added | Stéphane Chazelas | @Tensibai, of all systems concerned by U&L, most of them (Solaris, FreeBSD, HP/UX, AIX, most embedded Linux systems...) don't come with bash installed by default. bash is mostly found only on Apple macOS and GNU systems (I suppose that's what you call major distributions), though many systems also have it as an optional package (like zsh, tcl, python...) | |
| Nov 30, 2016 at 16:21 | comment | added | Wildcard | @Tensibai, Ubuntu uses dash as the default /bin/sh. There are others. As for Awk, stick to the POSIX features (which is what I linked to) and the particular implementation won't matter. And yes, that answer with grep and awk uses no Bashisms and could have a #!/bin/sh shebang. | |
| Nov 30, 2016 at 10:00 | comment | added | Tensibai | @Wildcard I slightly disagree for Awk (and which one, mawk, gawk ?). I agree sh will be present, but I fail to see any major distribution where it is not provided by bash. (And side note If you have a look at the link in first comment, it just use grep, awk and take advantage of the path expansion of the shell, I think sh will do as well as bash). | |
| Nov 30, 2016 at 9:48 | comment | added | Wildcard | @Tensibai, you will find POSIX sh, Awk, Sed, grep, ed, ex, cut, sort, join...all with more reliability than Bash or Perl. | |
| Aug 22, 2016 at 12:05 | comment | added | Tensibai | Thanks to @StéphaneChazelas I just spent 1h reading the answers here :) The drawback I personally have with perl (or anything else than bash at all) is that I may not have the interpreter on some servers, whereas I'm pretty sure I'll find bash, so I tend to use bash by default. I agree you should not develop a 'normal' user interface in shell btw. | |
| Aug 5, 2016 at 16:29 | history | edited | F. Hauri - Give Up GitHub | CC BY-SA 3.0 | added 6 characters in body |
| Aug 5, 2016 at 16:26 | comment | added | F. Hauri - Give Up GitHub | @StéphaneChazelas I've posted a perl version on my answer | |
| Aug 5, 2016 at 16:16 | history | edited | F. Hauri - Give Up GitHub | CC BY-SA 3.0 | added 385 characters in body |
| Aug 5, 2016 at 16:10 | comment | added | F. Hauri - Give Up GitHub | @StéphaneChazelas I agree, bash is probably the slowest shell people could use today, but the most widely used anyway. | |
| Aug 5, 2016 at 14:58 | comment | added | Stéphane Chazelas | Good example. Your approach is certainly more efficient than lololux one, but note how tensibai's answer (the right way to do this IMO, that is without using shell loops) is orders of magnitude faster than yours. And yours is a lot faster if you don't use bash. (over 3 times as fast with ksh93 in my test on my system). bash is generally the slowest shell. Even zsh is twice as fast on that script. You also have a few issues with unquoted variables and the usage of read. So you are actually illustrating a lot of my points here. | |
| Aug 5, 2016 at 13:35 | history | answered | F. Hauri - Give Up GitHub | CC BY-SA 3.0 |