Re: delimiters with more than one character? ...

2020-08-06 Thread John Crawley
On 2020-08-06 20:33, Greg Wooledge wrote: For short strings, doing this sort of parsing in bash is fine. But as you can see, on large inputs, it does not scale well. The fact that each iteration makes a *copy* of nearly the entire remaining input doesn't help matters, either -- right off the

Re: delimiters with more than one character? ...

2020-08-06 Thread Greg Wooledge
On Thu, Aug 06, 2020 at 11:57:47AM +0900, John Crawley wrote: > I likely don't have a sufficient grasp of that "spirit" to comment there :) > but as for "hideously slow", remain to be convinced. Bash string > modifications seem to be pretty fast. Would very long strings requiring > multiple runs

Re: delimiters with more than one character? ...

2020-08-05 Thread John Crawley
On 2020-08-05 22:06, Greg Wooledge wrote: On Wed, Aug 05, 2020 at 03:04:32PM +0900, John Crawley wrote: This method cuts off the first part of the string, up to the delimiter, and adds it to the array, then continues with what's left of the string until there's none left: Yes, that's a valid

Re: delimiters with more than one character? ...

2020-08-05 Thread Greg Wooledge
On Wed, Aug 05, 2020 at 03:04:32PM +0900, John Crawley wrote: > This method cuts off the first part of the string, up to the delimiter, and > adds it to the array, then continues with what's left of the string until > there's none left: Yes, that's a valid approach, although not one that most

Re: delimiters with more than one character? ...

2020-08-05 Thread John Crawley
On 2020-07-14 21:52, Albretch Mueller wrote: I have a string delimited by two characters: "\|" _S=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc " which then I need to turn into a array looking like: _S_AR=( " 34 + 45" " abc" " 1 2 3" " c" "123abc" ) Is it possible to do such things in

Re: tmpfs is not a ramdisk (was: delimiters with more than one character? ...)

2020-07-18 Thread tomas
On Fri, Jul 17, 2020 at 02:25:22PM -0400, rhkra...@gmail.com wrote: [...] > As far as the tmpfs stuff in RAM, it basically disappears when the power > decays > (after a not too long delay) and barring some kind of NSA techniques to > capture it? Unless (parts of) it have been swapped to

Re: tmpfs is not a ramdisk (was: delimiters with more than one character? ...)

2020-07-17 Thread Zenaan Harkness
On Fri, Jul 17, 2020 at 02:25:22PM -0400, rhkra...@gmail.com wrote: > On Friday, July 17, 2020 12:09:05 PM David Wright wrote: > > On Fri 17 Jul 2020 at 13:22:12 (+0200), Nicolas George wrote: > > > rhkra...@gmail.com (12020-07-17): > > […] > > > > > > Among other things, should I be worried that

Re: tmpfs is not a ramdisk (was: delimiters with more than one character? ...)

2020-07-17 Thread rhkramer
On Friday, July 17, 2020 12:09:05 PM David Wright wrote: > On Fri 17 Jul 2020 at 13:22:12 (+0200), Nicolas George wrote: > > rhkra...@gmail.com (12020-07-17): > […] > > > > Among other things, should I be worried that it won't disappear on > > > power loss / reboot? > > > > Depends on what kind

Re: tmpfs is not a ramdisk (was: delimiters with more than one character? ...)

2020-07-17 Thread David Wright
On Fri 17 Jul 2020 at 13:22:12 (+0200), Nicolas George wrote: > rhkra...@gmail.com (12020-07-17): […] > > Among other things, should I be worried that it won't disappear on power > > loss > > / reboot? > > Depends on what kind of disappear you want. If all you want is not to > have to worry

Re: delimiters with more than one character?

2020-07-17 Thread Dan Ritter
David Wright wrote: > On Thu 16 Jul 2020 at 15:27:06 (-0400), Dan Ritter wrote: > > William Michels wrote: > > > I've slowly been learning the Raku programming language (AKA Perl6), and > > > > Please don't call it that. Perl 1-5 have a clear relationship, and that > > relationship continues

Re: delimiters with more than one character? ...

2020-07-17 Thread Greg Wooledge
On Fri, Jul 17, 2020 at 07:13:04AM -0400, rhkra...@gmail.com wrote: > On Friday, July 17, 2020 04:45:00 AM Nicolas George wrote: > > Zenaan Harkness (12020-07-17): > > > And mount /tmp as ramdisk ftw. > > > > tmpfs is not a ramdisk. > > I'm not the op, but, in what sense do you say that? People

tmpfs is not a ramdisk (was: delimiters with more than one character? ...)

2020-07-17 Thread Nicolas George
rhkra...@gmail.com (12020-07-17): > I'm not the op, but, in what sense do you say that? tmpfs is FILESYSTEM backed in memory. A ramdisk is a kind of DISK, i.e. a block device, backed in memory and in which you can store a filesystem if you want. There are significant differences, like the fact

Re: delimiters with more than one character? ...

2020-07-17 Thread rhkramer
On Friday, July 17, 2020 04:45:00 AM Nicolas George wrote: > Zenaan Harkness (12020-07-17): > > And mount /tmp as ramdisk ftw. > > tmpfs is not a ramdisk. I'm not the op, but, in what sense do you say that? I use tmpfs filesystems for files that either I want fast access to (ram speed) or want

Re: delimiters with more than one character? ...

2020-07-17 Thread Nicolas George
Zenaan Harkness (12020-07-17): > And mount /tmp as ramdisk ftw. tmpfs is not a ramdisk. Regards, -- Nicolas George signature.asc Description: PGP signature

Re: delimiters with more than one character?

2020-07-16 Thread David Wright
On Thu 16 Jul 2020 at 15:27:06 (-0400), Dan Ritter wrote: > William Michels wrote: > > I've slowly been learning the Raku programming language (AKA Perl6), and > > Please don't call it that. Perl 1-5 have a clear relationship, and that > relationship continues in Perl 7 and subsequent versions.

Re: delimiters with more than one character? ...

2020-07-16 Thread Zenaan Harkness
On Thu, Jul 16, 2020 at 09:57:12AM -0400, Greg Wooledge wrote: > On Thu, Jul 16, 2020 at 03:52:01PM +0200, Thomas Schmitt wrote: > > I tried > > > > echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | \ > > sed -e 's/\\|/\n/g' | \ > > mapfile -t _S_AR > > > > with no visible effect on the

Re: delimiters with more than one character? ...

2020-07-16 Thread Zenaan Harkness
On Thu, Jul 16, 2020 at 07:56:57AM -0400, Greg Wooledge wrote: > On Thu, Jul 16, 2020 at 01:30:02PM +0200, Thomas Schmitt wrote: > > Hi, > > > > Eric S Fraga wrote: > > > echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | sed -e 's/\\|/\n/g' > > > > I came that far too. One can wrap the result in

Re: delimiters with more than one character?

2020-07-16 Thread William Michels
On Thu, Jul 16, 2020 at 12:03 PM Nicolas George wrote: > > Observe your output carefully. You'll notice that the string you defined > does not actually contain any backslash. > > Regards, > > Nicolas George Thank you, Nicholas! Looks like the trick for Raku one-liners on the bash command line

Re: delimiters with more than one character?

2020-07-16 Thread Dan Ritter
William Michels wrote: > mailto:debian-user@lists.debian.org?in-reply-to=< > cafakbwhn7crfsov60mr9tf4vus1duv4cnqohbbdyx-awoxw...@mail.gmail.com>subject=Re:%20Re: > delimiters with more than one character? ...">debian-user@lists.debian.org > > > I've slowly be

Re: delimiters with more than one character?

2020-07-16 Thread Greg Wooledge
On Thu, Jul 16, 2020 at 11:42:10AM -0700, William Michels wrote: > I've slowly been learning the Raku programming language (AKA Perl6), and > while I'm far from being an expert, this is the first solution I came up > with (raku one-or-two-liners, at the bash command prompt): > > user@mbook:~$

Re: delimiters with more than one character?

2020-07-16 Thread Nicolas George
William Michels (12020-07-16): > mailto:debian-user@lists.debian.org?in-reply-to=< > cafakbwhn7crfsov60mr9tf4vus1duv4cnqohbbdyx-awoxw...@mail.gmail.com>subject=Re:%20Re: > delimiters with more than one character? ...">debian-user@lists.debian.org > ??? > I've

Re: delimiters with more than one character?

2020-07-16 Thread William Michels
mailto:debian-user@lists.debian.org?in-reply-to=< cafakbwhn7crfsov60mr9tf4vus1duv4cnqohbbdyx-awoxw...@mail.gmail.com>subject=Re:%20Re: delimiters with more than one character? ...">debian-user@lists.debian.org I've slowly been learning the Raku programming language (AKA Perl6), and

Re: delimiters with more than one character? ...

2020-07-16 Thread Greg Wooledge
On Thu, Jul 16, 2020 at 03:52:01PM +0200, Thomas Schmitt wrote: > I tried > > echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | \ > sed -e 's/\\|/\n/g' | \ > mapfile -t _S_AR > > with no visible effect on the array _S_AR. bash 4.3.30 and 5.0.11. You can't use a pipeline, because each

Re: delimiters with more than one character? ...

2020-07-16 Thread Thomas Schmitt
Hi, Eric S Fraga wrote: > See the "\n" (newline) in the replacement pattern? Of course. Else there would be only one output line. Greg Wooledge wrote: > If you've got an input stream with one element per line that you want > to import into a bash array, you use the "mapfile" (or "readarray") >

Re: delimiters with more than one character? ...

2020-07-16 Thread Eric S Fraga
On Thursday, 16 Jul 2020 at 13:30, Thomas Schmitt wrote: > Eric S Fraga wrote: >> echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | sed -e 's/\\|/\n/g' > > But how to get the lines into the array ? See the "\n" (newline) in the replacement pattern? -- Eric S Fraga via Emacs 28.0.50 & org 9.3.7 on

Re: delimiters with more than one character? ...

2020-07-16 Thread Greg Wooledge
On Thu, Jul 16, 2020 at 01:30:02PM +0200, Thomas Schmitt wrote: > Hi, > > Eric S Fraga wrote: > > echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | sed -e 's/\\|/\n/g' > > I came that far too. One can wrap the result in quotation marks by adding > | sed -e 's/^.*$/"&"/' > > But how to get the

Re: delimiters with more than one character? ...

2020-07-16 Thread Thomas Schmitt
Hi, Eric S Fraga wrote: > echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | sed -e 's/\\|/\n/g' I came that far too. One can wrap the result in quotation marks by adding | sed -e 's/^.*$/"&"/' But how to get the lines into the array ? I did not find much info in man bash how to do this with

Re: delimiters with more than one character? ...

2020-07-16 Thread Eric S Fraga
Try sed: echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | sed -e 's/\\|/\n/g' HTH, eric -- Eric S Fraga via Emacs 28.0.50 & org 9.3.7 on Debian bullseye/sid

Re: delimiters with more than one character? ...

2020-07-15 Thread Nicolas George
Bob Weber (12020-07-15): > which replaces \| with a single character which is known not to be in > the input data For the third time, and on top of what other people have told you: THERE ARE NO CHARACTERS KNOWN NOT TO BE IN THE INPUT. Regards, -- Nicolas George signature.asc Description:

Re: delimiters with more than one character? ...

2020-07-15 Thread Alessandro Baggi
Il 14/07/20 14:52, Albretch Mueller ha scritto: I have a string delimited by two characters: "\|" _S=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc " which then I need to turn into a array looking like: _S_AR=( " 34 + 45" " abc" " 1 2 3" " c" "123abc" ) I can't make awk or tr work in the

Re: delimiters with more than one character? ...

2020-07-15 Thread Greg Wooledge
On Wed, Jul 15, 2020 at 10:11:08AM -0400, Bob Weber wrote: > Which is why I showed this: > > tr -s '\\\|' '\|' > > which replaces \| with a single character which is known not to be in the > input data and usable as a awk field separator. It just happens to be a | You misunderstood my point.

Re: delimiters with more than one character? ...

2020-07-15 Thread The Wanderer
On 2020-07-15 at 10:11, Bob Weber wrote: > On 7/15/20 8:44 AM, Greg Wooledge wrote: > >> On Wed, Jul 15, 2020 at 08:34:36AM -0400, Bob Weber wrote: >> >>> My only purpose was to show how tr could be used to handle >>> multiple characters as a delimiter either as tr -s '\\\|' '\|' >>> or >> >>

Re: delimiters with more than one character? ...

2020-07-15 Thread Bob Weber
On 7/15/20 8:44 AM, Greg Wooledge wrote: On Wed, Jul 15, 2020 at 08:34:36AM -0400, Bob Weber wrote: My only purpose was to show how tr could be used to handle multiple characters as a delimiter either as tr -s '\\\|' '\|' or The problem is, it can't, at least not the way you showed. The

Re: delimiters with more than one character? ...

2020-07-15 Thread Nicolas George
Bob Weber (12020-07-15): > My only purpose was to show how tr could be used to handle multiple > characters as a delimiter either as tr -s '\\\|' '\|' or A simple combinatorics argument should convince you that the trick of turning a 2-chars delimiter into a 1-char delimiter cannot work in all

Re: delimiters with more than one character? ...

2020-07-15 Thread Greg Wooledge
On Wed, Jul 15, 2020 at 08:34:36AM -0400, Bob Weber wrote: > My only purpose was to show how tr could be used to handle multiple > characters as a delimiter either as tr -s '\\\|' '\|' or The problem is, it can't, at least not the way you showed. The original example, sadly, did NOT contain

Re: delimiters with more than one character? ...

2020-07-15 Thread Bob Weber
On 7/15/20 6:29 AM, Albretch Mueller wrote: the thing is that that was the one liner passed to a find command which then I need to use as an array lbrtchx My only purpose was to show how tr could be used to handle multiple characters as a delimiter either as tr -s '\\\|' '\|' or tr -d

Re: delimiters with more than one character? ...

2020-07-15 Thread David Wright
On Wed 15 Jul 2020 at 06:29:38 (-0400), Albretch Mueller wrote: > On 7/14/20, Nicolas George wrote: > > Bob Weber (12020-07-14): > >> echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | tr -d '\\' | awk 'BEGIN { > >> FS="|" } { printf " > >>

Re: delimiters with more than one character? ...

2020-07-15 Thread Greg Wooledge
On Wed, Jul 15, 2020 at 06:29:38AM -0400, Albretch Mueller wrote: > On 7/14/20, Nicolas George wrote: > > Bob Weber (12020-07-14): > >> echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | tr -d '\\' | awk 'BEGIN { > >> FS="|" } { printf " > >>

Re: delimiters with more than one character? ...

2020-07-15 Thread Albretch Mueller
On 7/14/20, Nicolas George wrote: > Bob Weber (12020-07-14): >> echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | tr -d '\\' | awk 'BEGIN { >> FS="|" } { printf " >> _S_AR=(\n\"%s\"\n\"%s\"\n\"%s\"\n\"%s\"\n\"%s\"\n)\n",$1,$2,$3,$4,$5}' > > Have you considered that pipes without backslashes are not

Re: delimiters with more than one character? ...

2020-07-14 Thread Nicolas George
Bob Weber (12020-07-14): > echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | tr -d '\\' | awk 'BEGIN { > FS="|" } { printf " > _S_AR=(\n\"%s\"\n\"%s\"\n\"%s\"\n\"%s\"\n\"%s\"\n)\n",$1,$2,$3,$4,$5}' Have you considered that pipes without backslashes are not supposed to be separators? Regards, --

Re: delimiters with more than one character? ...

2020-07-14 Thread Bob Weber
On 7/14/20 8:52 AM, Albretch Mueller wrote: I have a string delimited by two characters: "\|" _S=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc " which then I need to turn into a array looking like: _S_AR=( " 34 + 45" " abc" " 1 2 3" " c" "123abc" ) Try: echo " 34 + 45 \| abc \| 1 2 3 \|

Re: delimiters with more than one character? ...

2020-07-14 Thread Alex Mestiashvili
On 7/14/20 3:05 PM, Greg Wooledge wrote: On Tue, Jul 14, 2020 at 03:04:38PM +0200, Alex Mestiashvili wrote: Since you anyway use tools like awk or tr, here is the perl code: echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | perl -F'\\\|' -lanE 'say "\"".$_."\"" for @F' If you're going to call

Re: delimiters with more than one character? ...

2020-07-14 Thread Nicolas George
Albretch Mueller (12020-07-14): > I have a string delimited by two characters: "\|" > > _S=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc " > > which then I need to turn into a array looking like: > > _S_AR=( > " 34 + 45 " > " abc " > " 1 2 3 " > " c" > "123abc " > ) > > I can't make awk or tr

Re: delimiters with more than one character? ...

2020-07-14 Thread Nicolas George
Greg Wooledge (12020-07-14): > > echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | perl -F'\\\|' -lanE 'say > > "\"".$_."\"" for @F' > > If you're going to call on perl to help split the string into an > array, you might as well throw bash away and write the entire program > in perl instead. I

Re: delimiters with more than one character? ...

2020-07-14 Thread Greg Wooledge
On Tue, Jul 14, 2020 at 03:04:38PM +0200, Alex Mestiashvili wrote: > Since you anyway use tools like awk or tr, here is the perl code: > > echo " 34 + 45 \| abc \| 1 2 3 \| c\|123abc " | perl -F'\\\|' -lanE 'say > "\"".$_."\"" for @F' If you're going to call on perl to help split the string into

Re: delimiters with more than one character? ...

2020-07-14 Thread Greg Wooledge
On Tue, Jul 14, 2020 at 02:52:08PM +0200, Albretch Mueller wrote: > I have a string delimited by two characters: "\|" > > _S=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc " > > which then I need to turn into a array looking like: > > _S_AR=( > " 34 + 45 " > " abc " > " 1 2 3 " > " c" > "123abc "

Re: delimiters with more than one character? ...

2020-07-14 Thread Alex Mestiashvili
On 7/14/20 2:52 PM, Albretch Mueller wrote: I have a string delimited by two characters: "\|" _S=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc " which then I need to turn into a array looking like: _S_AR=( " 34 + 45" " abc" " 1 2 3" " c" "123abc" ) I can't make awk or tr work in the

delimiters with more than one character? ...

2020-07-14 Thread Albretch Mueller
I have a string delimited by two characters: "\|" _S=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc " which then I need to turn into a array looking like: _S_AR=( " 34 + 45 " " abc " " 1 2 3 " " c" "123abc " ) I can't make awk or tr work in the way I need and all examples I have found use only