zsh-users
 help / color / mirror / code / Atom feed
From: Kurtis Rader <krader@skepticism.us>
To: meino.cramer@gmx.de
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: splitting and assigning
Date: Sat, 24 May 2014 07:27:29 -0700	[thread overview]
Message-ID: <CABx2=D8M71M398BCTuTkpsS0vNbxo1hBwsxAnuEKPq7hpM_J3A@mail.gmail.com> (raw)
In-Reply-To: <20140524054323.GB4047@solfire>

[-- Attachment #1: Type: text/plain, Size: 1113 bytes --]

Use the right tool for the job. At some point you need to consider
switching to a different language. In Python the task is trivial. This is
from an iPython interactive session:

In [1]: data = ['md5sum#1  pathname#1', 'md5sum#2  pathname#2']

In [2]: data = [d.split() for d in data]

In [3]: data
Out[3]: [['md5sum#1', 'pathname#1'], ['md5sum#2', 'pathname#2']]

In [4]: checksums, pathnames = zip(*data)

In [5]: checksums
Out[5]: ('md5sum#1', 'md5sum#2')

In [6]: pathnames
Out[6]: ('pathname#1', 'pathname#2')




On Fri, May 23, 2014 at 10:43 PM, <meino.cramer@gmx.de> wrote:

> Hi,
>
> I have a looooooong list, whgich consists
> of a 32 character long checksum (from md5sum),
> two spaces and a absolute path with the checksummed file.
>
> I want to split each line into two parts:
> the checksum and the path/file and assign each part
> to a separate variable.
>
> I tried to put this into a one-liner and failed using
> ${(s:  :)line}.
>
> How can I do that?
>
> Best regards and have a nice weekend!
> Best regards,
> mcc
>
>
>
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

  reply	other threads:[~2014-05-24 14:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-24  5:43 meino.cramer
2014-05-24 14:27 ` Kurtis Rader [this message]
2014-05-24 15:12 ` Eric Cook
2014-05-25  3:20 ` S. Cowles

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABx2=D8M71M398BCTuTkpsS0vNbxo1hBwsxAnuEKPq7hpM_J3A@mail.gmail.com' \
    --to=krader@skepticism.us \
    --cc=meino.cramer@gmx.de \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).