Re: (resend)
Re: (resend)
- Subject: Re: (resend)
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 30 Mar 2010 07:06:18 -0400
First, extracting data from ls -l output is tricky. It's formatted
for human, not automatic, consumption - e.g. the format on the
timestamp changes depending on how long ago it was. Chances are
there's a better way to get any of the pieces of information in that
listing programmatically.
The traditional way of splitting on whitespace is the Unix tool "awk",
which will happily treat any number of consecutive spaces or tabs as a
single delimiter. Which is fine on the shell script side, but then
you have to somehow get this separation back out of awk into AS, which
is doable but requires a bit more work (explicit loops and such) on
the awk side.
With Perl, whose default autosplit behavior is the same as awk's, you
can make it a one liner:
set text item delimiters to {"&"}
do shell script "echo 1 2 3 | perl -lane 'print join(\"&\", @F)'"
text items of result
-- {"1", "2", "3"}
you just need to make sure the line you're processing doesn't contain
your chosen delimiter - there's no escape mechanism.
On Tuesday, March 30, 2010, Alex Zavatone <email@hidden> wrote:
>
> On Mar 30, 2010, at 1:31 AM, Shane Stanley wrote:
>
>> On 30/3/10 4:45 PM, "Alex Zavatone" <email@hidden> wrote:
>>
>>> Ok. I come from the world of "one space or twenty thousand spaces between two
>>> words still means that you still have two words".
>>
>> Which is what happens in AS.
>
> I tried that.
>
> It's almost 2 am. I'll get back to this tomorrow.
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden