Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: splitting and assigning
- X-seq: zsh-users 18849
- From: Kurtis Rader <krader@xxxxxxxxxxxxx>
- To: meino.cramer@xxxxxx
- Subject: Re: splitting and assigning
- Date: Sat, 24 May 2014 07:27:29 -0700
- Cc: Zsh Users <zsh-users@xxxxxxx>
- In-reply-to: <20140524054323.GB4047@solfire>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20140524054323.GB4047@solfire>
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@xxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author