Unix Shell - Re: How to convert a shell string (separated by spaces) to a shell

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > February 2007 > Re: How to convert a shell string (separated by spaces) to a shell





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: How to convert a shell string (separated by spaces) to a shell
Bruce Barnett

2007-02-26, 1:21 am

melroysoares@hotmail.com writes:

> Let's say I have a shell string a = " this is a shell string" . How do
> I convert it
> into an array (in C-shell) so that each word in the string is an
> element.


Besides the other comments, in csh, you use

set a = "this is a shell string"
set b = ( $a )
echo $b[1] $b[2]

outputs "this is"

As Chris points out - Beware the C shell.


--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com