* zsh equivalent to string manipulation with offset and length
@ 2008-10-20 11:15 xulxer
2008-10-20 11:21 ` Clint Adams
0 siblings, 1 reply; 4+ messages in thread
From: xulxer @ 2008-10-20 11:15 UTC (permalink / raw)
To: zsh-users
Hi,
if have searched the manuals for hours now and didn't find anything
useful.
Say
string="abcdefghijklmnopqrstuvwxyz"
and i want to echo string from position 10 to 15. In bash i could do:
echo ${string:10:5}
but not in zsh? What is the zsh equivalent? This sort of string
manipulation is so widely used, why not make it the default in zsh, too?
Kind regards and thanks for any help
Chris
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: zsh equivalent to string manipulation with offset and length
2008-10-20 11:15 zsh equivalent to string manipulation with offset and length xulxer
@ 2008-10-20 11:21 ` Clint Adams
2008-10-20 16:06 ` Dan Nelson
0 siblings, 1 reply; 4+ messages in thread
From: Clint Adams @ 2008-10-20 11:21 UTC (permalink / raw)
To: xulxer; +Cc: zsh-users
On Mon, Oct 20, 2008 at 01:15:06PM +0200, xulxer wrote:
> string="abcdefghijklmnopqrstuvwxyz"
> echo ${string:10:5}
string="abcdefghijklmnopqrstuvwxyz"
print ${string[11,15]}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: zsh equivalent to string manipulation with offset and length
2008-10-20 11:21 ` Clint Adams
@ 2008-10-20 16:06 ` Dan Nelson
2008-10-20 17:16 ` Rocky Bernstein
0 siblings, 1 reply; 4+ messages in thread
From: Dan Nelson @ 2008-10-20 16:06 UTC (permalink / raw)
To: xulxer, zsh-users
In the last episode (Oct 20), Clint Adams said:
> On Mon, Oct 20, 2008 at 01:15:06PM +0200, xulxer wrote:
> > string="abcdefghijklmnopqrstuvwxyz"
> > echo ${string:10:5}
>
> string="abcdefghijklmnopqrstuvwxyz"
> print ${string[11,15]}
, which matches the syntax for accessing array elements, and is much
more readable than bash's syntax imho.
--
Dan Nelson
dnelson@allantgroup.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: zsh equivalent to string manipulation with offset and length
2008-10-20 16:06 ` Dan Nelson
@ 2008-10-20 17:16 ` Rocky Bernstein
0 siblings, 0 replies; 4+ messages in thread
From: Rocky Bernstein @ 2008-10-20 17:16 UTC (permalink / raw)
To: zsh-users
On Mon, Oct 20, 2008 at 12:06 PM, Dan Nelson <dnelson@allantgroup.com> wrote:
> In the last episode (Oct 20), Clint Adams said:
>> On Mon, Oct 20, 2008 at 01:15:06PM +0200, xulxer wrote:
>> > string="abcdefghijklmnopqrstuvwxyz"
>> > echo ${string:10:5}
>>
>> string="abcdefghijklmnopqrstuvwxyz"
>> print ${string[11,15]}
>
> , which matches the syntax for accessing array elements, and is much
> more readable than bash's syntax imho.
^^^^^^^
bash's and ksh's syntax. Given this, it would be a nice feature to add
when the KSHARRAYS option is set.
>
> --
> Dan Nelson
> dnelson@allantgroup.com
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-10-20 22:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-20 11:15 zsh equivalent to string manipulation with offset and length xulxer
2008-10-20 11:21 ` Clint Adams
2008-10-20 16:06 ` Dan Nelson
2008-10-20 17:16 ` Rocky Bernstein
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).