Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #264653
| From | Albretch Mueller <lbrtchx@gmail.com> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... |
| Date | 2023-12-11 20:00 +0100 |
| Message-ID | <HJTFw-cTrx-9@gated-at.bofh.it> (permalink) |
| References | (4 earlier) <HJNTr-cQ17-7@gated-at.bofh.it> <HJOmt-cQqs-1@gated-at.bofh.it> <HJOwa-cQtH-11@gated-at.bofh.it> <HJP8R-cQVR-3@gated-at.bofh.it> <HJPVg-cRbE-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 12/11/23, Greg Wooledge <greg@wooledge.org> wrote: > 1) Many implementations of echo will interpret parts of their argument(s), > in addition to processing options like -n. If you want to print a > variable's contents to standard output without *any* interpretation, > use printf. > > printf %s "$myvar" > printf '%s\n' "$myvar" > I will use "printf ..." from now on. > 2) As tomas already told you, the square brackets in > > tr -c -s '[A-Za-z0-9.]' _ > > are literal. You're using a command which will keep left and right > square brackets in the input, *not* replacing them with underscores. > This may not be what you want. My mistake, even though it didn't get in the way of what I was trying to do. I replaced :alnum: by what I thought it meant and left the brackets. > 3) In locales other than C or POSIX, ranges like A-Z are *not* necessarily > synonyms for [:upper:]. As I've already mentioned, GNU tr is known to > contain bugs, so you're getting lucky here. The bugs in GNU tr happen > to work the way you're expecting, so that A-Z is treated like [:upper:] > when it should not be. If at some point in the future GNU tr is fixed > to conform to POSIX, your script may break. > > The correct tr command you should be using if you want to retain > accented letters (as defined in your locale) is: > > tr -c -s '[:alnum:].' _ > > If you want to discard accented letters, then either of these is OK: > > LC_COLLATE=C tr -c -s '[:alnum:].' _ > LC_COLLATE=C tr -c -s 'A-Za-z0-9.' _ > I like your second one liner much better (LC_COLLATE=C tr -c -s 'A-Za-z0-9.' _) I tend to avoid '[:alnum:].' because the intended meaning of "ALphabetic et NUMeric" characters, even though it depends on the locale has a strong ASCII accent to it. > Thus, we come full circle. Yes, we did. Thank you, lbrtchx
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... Albretch Mueller <lbrtchx@gmail.com> - 2023-12-11 04:00 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... Greg Wooledge <greg@wooledge.org> - 2023-12-11 04:40 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... Albretch Mueller <lbrtchx@gmail.com> - 2023-12-11 09:10 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... <tomas@tuxteam.de> - 2023-12-11 09:40 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... Albretch Mueller <lbrtchx@gmail.com> - 2023-12-11 12:30 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... tomas@tuxteam.de - 2023-12-11 13:00 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... Greg Wooledge <greg@wooledge.org> - 2023-12-11 13:40 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... Greg Wooledge <greg@wooledge.org> - 2023-12-11 13:50 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... <tomas@tuxteam.de> - 2023-12-11 14:20 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... Greg Wooledge <greg@wooledge.org> - 2023-12-11 14:30 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... Albretch Mueller <lbrtchx@gmail.com> - 2023-12-11 15:10 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... Max Nikulin <manikulin@gmail.com> - 2023-12-11 16:00 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... Greg Wooledge <greg@wooledge.org> - 2023-12-11 16:00 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... <tomas@tuxteam.de> - 2023-12-11 16:10 +0100
"echo" literally in sh scripts (was: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ...) Stefan Monnier <monnier@iro.umontreal.ca> - 2023-12-11 16:20 +0100
Re: "echo" literally in sh scripts (was: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ...) Greg Wooledge <greg@wooledge.org> - 2023-12-11 18:00 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... Albretch Mueller <lbrtchx@gmail.com> - 2023-12-11 20:00 +0100
Re: why would "tr --complement --squeeze-repeats ..." append the substitution char once more? ... debian-user@howorth.org.uk - 2023-12-11 19:20 +0100
csiph-web