"Dietmar P. Schindler" writes:
> Doesn't the example I gave above show that quotes are removed? If they
> weren't, how could word aa with pattern a""a constitute a match?
As you say, >a""a< matches as a case-pattern when the case word is
>aa<. But that's not due to quote removal, because what th
Fun to see different techniques from different people. I have also
played with this interesting problem. In my environment, the following
implementations seem to be the fastest.
f21b() { local -a "arr=('\${1:'{0..$((${#1}-1))}':1}')";
arr=("${arr[@]@P}"); } # Any strings
f31() { local arr i=${#1}
On Tue, Aug 24, 2021, at 4:44 PM, Dietmar P. Schindler wrote:
> Doesn't the example I gave above show that quotes are removed? If they
> weren't, how could word aa with pattern a""a constitute a match?
The quotes are handled by the matching process itself, *not* as
part of the usual shell expansio
- Original Message -
From: "Andreas Schwab"
To:
Cc:
Sent: Tuesday, August 24, 2021 3:19 PM
Subject: Re: Defect in manual section "Conditional Constructs" / case
On Aug 24 2021, dietmar_schind...@web.de wrote:
In the section
https://www.gnu.org/software/bash/manual/bash.html#Conditi
On 2021/08/24 05:06, Greg Wooledge wrote:
Looks like the efficiency of "read -ra" vs. a shell loop just about makes
up for the system calls used for the here string (f6 and f7 are almost
tied in overall speed, with f6 just a *tiny* bit faster). Good to know.
If you set your TIMEFORM
On Tue, Aug 24, 2021 at 04:16:46PM +0200, Léa Gris wrote:
> string2array() {
> # Splits the string's characters into the array
> # $1: The input string
> # $2: The output array name
> [[ "$1" =~ ${1//?/(.)} ]]
> # shellcheck disable=SC2178 # shellcheck broken nameref type check
> local
On Tue, Aug 24, 2021 at 04:16:46PM +0200, Léa Gris wrote:
> Le 24/08/2021 à 15:09, Mike Jonkmans écrivait :
> > This seems to be the fastest:
> > f12 () { [[ "$1" =~ ${1//?/(.)} ]]; local arr=( "${BASH_REMATCH[@]:1}" ); }
>
> Awesome Mike, would you like to add this answer to SO?
>
> It would be
On Tue, Aug 24, 2021 at 09:24:35AM -0400, Greg Wooledge wrote:
> On Tue, Aug 24, 2021 at 03:09:55PM +0200, Mike Jonkmans wrote:
> > This seems to be the fastest:
> > f12 () { [[ "$1" =~ ${1//?/(.)} ]]; local arr=( "${BASH_REMATCH[@]:1}" ); }
> > time for ((i=1; i<=1; i++)); do f0 682390; done
>
Le 24/08/2021 à 15:09, Mike Jonkmans écrivait :
This seems to be the fastest:
f12 () { [[ "$1" =~ ${1//?/(.)} ]]; local arr=( "${BASH_REMATCH[@]:1}" ); }
time for ((i=1; i<=1; i++)); do f0 682390; done
real0m0,296s
user0m0,296s
sys 0m0,000s
Awesome Mike, would you like to add th
On Tue, Aug 24, 2021 at 03:09:55PM +0200, Mike Jonkmans wrote:
> This seems to be the fastest:
> f12 () { [[ "$1" =~ ${1//?/(.)} ]]; local arr=( "${BASH_REMATCH[@]:1}" ); }
> time for ((i=1; i<=1; i++)); do f0 682390; done
> real0m0,296s
> user0m0,296s
> sys 0m0,000s
Your CPU is a
On Aug 24 2021, dietmar_schind...@web.de wrote:
> In the section
> https://www.gnu.org/software/bash/manual/bash.html#Conditional-Constructs
> in the description of the "case" command there is no mention (as far as I
> can see, it doesn't follow from the documented expansions etc.) that a
> _patte
On Tue, Aug 24, 2021 at 02:15:46PM +0200, Léa Gris wrote:
> Le 24/08/2021 à 14:06, Greg Wooledge écrivait :
>
> > unicorn:~$ f6() { local i n=${#1} arr; for ((i=0; i > arr[i]="${1:i:1}"; done; }
> > unicorn:~$ time for ((i=1; i<=1; i++)); do f6 682390; done
> > real 0.381 user 0.381 sys 0.00
(resending this from private account without the silly company "Confidelity
note")
In the section
https://www.gnu.org/software/bash/manual/bash.html#Conditional-Constructs in
the description of the "case" command there is no mention (as far as I can see,
it doesn't follow from the documented e
Le 24/08/2021 à 14:06, Greg Wooledge écrivait :
unicorn:~$ f6() { local i n=${#1} arr; for ((i=0; i
See my featured version to also capture space and newlines:
https://stackoverflow.com/a/68907322/7939871
--
Léa Gris
On Tue, Aug 24, 2021 at 01:31:35PM +0200, Léa Gris wrote:
> Le 23/08/2021 à 21:41, L A Walsh écrivait :
> >
> >
> > On 2021/08/23 12:10, Greg Wooledge wrote:
> > > On Mon, Aug 23, 2021 at 11:36:52AM -0700, L A Walsh wrote:
> > > > Starting with a number N, is there
> > > > an easy way to print it
Le 23/08/2021 à 21:41, L A Walsh écrivait :
On 2021/08/23 12:10, Greg Wooledge wrote:
On Mon, Aug 23, 2021 at 11:36:52AM -0700, L A Walsh wrote:
Starting with a number N, is there
an easy way to print its digits into an array?
n=988421
# Need extglob for the replacement pattern
shopt -s ex
16 matches
Mail list logo