Unix Shell - Re: KSH: Accessing individual words in a variable string (like

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > December 2007 > Re: KSH: Accessing individual words in a variable string (like





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: KSH: Accessing individual words in a variable string (like
Janis

2007-12-04, 7:34 am

On 4 Dez., 01:52, Generic Usenet Account <use...@sta.samsung.com>
wrote:
> On Nov 29, 7:38 pm, use...@sta.samsung.com wrote:
>
>
>
>
> The only thing that I can get to work is the following:
>
> presidents[0]=Washington
> presidents[1]=Adams
> presidents[2]=Jefferson
> presidents[3]=Madison
> presidents[4]=Monroe
> presidents[5]=Qunicy-Adams
> presidents[6]=Jackson
>
> echo ${presidents[0]} ${presidents[3]}
> ##### Could not find the KSH equivalent for echo
> $presidents[4-7]
>
> echo ${#presidents[*]}
>
> Is there some way to print a range of array elements?


See my reply upthread...

In ksh93, bash, ... (otherwise use the 'set - ...' approach)

echo ${presidents[@]:1:1} ${presidents[@]:4:4}

The second second number defines the number of elements (if omitted
until the end of the array list)... ${arrayvar[@]:index:length}

Janis

> Thanks
>
> [Courtesy:http://www.livefirelabs.com/unix_ti...ov_2003/1110...
>
> http://www.livefirelabs.com/unix_ti...ov_2003/1117...]


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com