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

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > November 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-11-30, 7:35 am

On 30 Nov., 02:38, use...@sta.samsung.com wrote:
> Kindly suggest the ksh equivalent of the following csh script snippet
>
> ##############################
> set presidents=(Washington Adams Jefferson Madison Monroe Qunicy-Adams
> Jackson)
>
> echo $presidents[1] $presidents[4-7]
> ##############################


What version of ksh are you using? Try one of...

set - Washington Adams Jefferson Madison Monroe Qunicy-Adams Jackson
echo $1 $4 $5 $6 $7

set - Washington Adams Jefferson Madison Monroe Qunicy-Adams Jackson
printf "%s" $1; shift 3; echo "$@"


set - Washington Adams Jefferson Madison Monroe Qunicy-Adams Jackson
echo ${@:1:1} ${@:4:4}

presidents=( Washington Adams Jefferson Madison Monroe Qunicy-Adams
Jackson )
echo ${presidents:1:1} ${presidents:4:4}


Janis
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com