Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #224796

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

Path csiph.com!goblin2!goblin.stu.neva.ru!aioe.org!bofh.it!news.nic.it!robomod
From Alex Mestiashvili <amestia@rsh2.donotuse.de>
Newsgroups linux.debian.user
Subject Re: delimiters with more than one character? ...
Date Tue, 14 Jul 2020 15:00:02 +0200
Message-ID <AssHo-5be-5@gated-at.bofh.it> (permalink)
References <AssHn-5be-3@gated-at.bofh.it>
X-Original-To Albretch Mueller <lbrtchx@gmail.com>, Debian Users ML <debian-user@lists.debian.org>
X-Mailbox-Line From debian-user-request@lists.debian.org Tue Jul 14 12:59:31 2020
Old-Return-Path <amestia@rsh2.donotuse.de>
X-Amavis-Spam-Status No, score=-5.065 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, LDO_WHITELIST=-5, RDNS_NONE=0.793, SARE_TOCC_CONS6s=0.141, WEIRD_QUOTING=0.001, WORD_WITHOUT_VOWELS=1] autolearn=no autolearn_force=no
X-Policyd-Weight using cached result; rate: -4.6
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0
MIME-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Language en-US
Content-Transfer-Encoding 7bit
X-Mailing-List <debian-user@lists.debian.org> archive/latest/765118
List-ID <debian-user.lists.debian.org>
List-URL <https://lists.debian.org/debian-user/>
List-Archive https://lists.debian.org/msgid-search/f7e97671-4da0-72ce-ea33-13109096e16a@rsh2.donotuse.de
Approved robomod@news.nic.it
Lines 34
Organization linux.* mail to news gateway
Sender robomod@news.nic.it
X-Original-Date Tue, 14 Jul 2020 15:04:38 +0200
X-Original-Message-ID <f7e97671-4da0-72ce-ea33-13109096e16a@rsh2.donotuse.de>
X-Original-References <CAFakBwiSVJDpghe_K7YSj12TyZGYikPSnTiNWLGHJLWmUx-xJw@mail.gmail.com>
Xref csiph.com linux.debian.user:224796

Show key headers only | View raw



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 way I need and all examples I
> have found use only one character.
> 
>    Is it possible to do such things in bash?
> 
>    lbrtchx
> 

Please share the solution you tried.

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'

Best,
Alex

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

delimiters with more than one character? ... Albretch Mueller <lbrtchx@gmail.com> - 2020-07-14 15:00 +0200
  Re: delimiters with more than one character? ... Alex Mestiashvili <amestia@rsh2.donotuse.de> - 2020-07-14 15:00 +0200
    Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-14 15:10 +0200
      Re: delimiters with more than one character? ... Nicolas George <george@nsup.org> - 2020-07-14 15:10 +0200
      Re: delimiters with more than one character? ... Alex Mestiashvili <amestia@rsh2.donotuse.de> - 2020-07-14 15:20 +0200
  Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-14 15:10 +0200
  Re: delimiters with more than one character? ... Nicolas George <george@nsup.org> - 2020-07-14 15:20 +0200
  Re: delimiters with more than one character? ... Nicolas George <george@nsup.org> - 2020-07-14 17:30 +0200
    Re: delimiters with more than one character? ... Albretch Mueller <lbrtchx@gmail.com> - 2020-07-15 12:30 +0200
      Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-15 14:00 +0200
      Re: delimiters with more than one character? ... David Wright <deblis@lionunicorn.co.uk> - 2020-07-15 14:30 +0200
      Re: delimiters with more than one character? ... Bob Weber <bobrweber@gmail.com> - 2020-07-15 14:40 +0200
        Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-15 14:50 +0200
          Re: delimiters with more than one character? ... Bob Weber <bobrweber@gmail.com> - 2020-07-15 16:20 +0200
            Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-15 16:30 +0200
            Re: delimiters with more than one character? ... The Wanderer <wanderer@fastmail.fm> - 2020-07-15 16:30 +0200
            Re: delimiters with more than one character? ... Nicolas George <george@nsup.org> - 2020-07-15 17:50 +0200
        Re: delimiters with more than one character? ... Nicolas George <george@nsup.org> - 2020-07-15 15:10 +0200
  Re: delimiters with more than one character? ... Bob Weber <bobrweber@gmail.com> - 2020-07-14 17:30 +0200
  Re: delimiters with more than one character? ... Alessandro Baggi <alessandro.baggi@gmail.com> - 2020-07-15 17:30 +0200
  Re: delimiters with more than one character? ... Eric S Fraga <e.fraga@ucl.ac.uk> - 2020-07-16 12:10 +0200
    Re: delimiters with more than one character? ... "Thomas Schmitt" <scdbackup@gmx.net> - 2020-07-16 13:40 +0200
      Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-16 14:00 +0200
        Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-16 16:00 +0200
          Re: delimiters with more than one character? ... Zenaan Harkness <zenaan@freedbms.net> - 2020-07-17 04:50 +0200
            Re: delimiters with more than one character? ... Nicolas George <george@nsup.org> - 2020-07-17 10:50 +0200
              Re: delimiters with more than one character? ... rhkramer@gmail.com - 2020-07-17 13:20 +0200
                tmpfs is not a ramdisk (was: delimiters with more than one  character? ...) Nicolas George <george@nsup.org> - 2020-07-17 13:30 +0200
                Re: tmpfs is not a ramdisk (was: delimiters with more than one  character? ...) David Wright <deblis@lionunicorn.co.uk> - 2020-07-17 18:20 +0200
                Re: tmpfs is not a ramdisk (was: delimiters with more than one character? ...) rhkramer@gmail.com - 2020-07-17 20:30 +0200
                Re: tmpfs is not a ramdisk (was: delimiters with more than one  character? ...) Zenaan Harkness <zenaan@freedbms.net> - 2020-07-18 07:20 +0200
                Re: tmpfs is not a ramdisk (was: delimiters with more than one  character? ...) <tomas@tuxteam.de> - 2020-07-18 10:40 +0200
                Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-17 13:40 +0200
        Re: delimiters with more than one character? ... "Thomas Schmitt" <scdbackup@gmx.net> - 2020-07-16 16:00 +0200
        Re: delimiters with more than one character? ... Zenaan Harkness <zenaan@freedbms.net> - 2020-07-17 04:50 +0200
      Re: delimiters with more than one character? ... Eric S Fraga <e.fraga@ucl.ac.uk> - 2020-07-16 15:00 +0200
  Re: delimiters with more than one character? ... John Crawley <john@bunsenlabs.org> - 2020-08-05 08:30 +0200
    Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-08-05 15:10 +0200
      Re: delimiters with more than one character? ... John Crawley <john@bunsenlabs.org> - 2020-08-06 05:00 +0200
        Re: delimiters with more than one character? ... Greg Wooledge <wooledg@eeg.ccf.org> - 2020-08-06 13:40 +0200
          Re: delimiters with more than one character? ... John Crawley <john@bunsenlabs.org> - 2020-08-07 03:10 +0200

csiph-web