![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Array inside an array | manas_ranjan | UNIX for Advanced & Expert Users | 5 | 06-10-2008 02:25 PM |
| Array with special Characters | donaldfung | UNIX for Dummies Questions & Answers | 1 | 06-08-2008 12:18 PM |
| 2D Array to display characters | Raynon | Shell Programming and Scripting | 16 | 05-15-2008 06:38 AM |
| How to declare an array to take more than 10,000 characters | pinky | Shell Programming and Scripting | 0 | 01-15-2008 10:38 PM |
| How to echo password characters | mukluk | UNIX for Dummies Questions & Answers | 4 | 09-12-2005 07:34 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
create array holding characters from sring then echo array.
Hi,
I wish to store $string1 in $string1array[] a character in each array element. Then i wish to echo the entire array to the screen so that it reads as the normal string again. I have been trying with the code below but does not work. Please help... To put string into array: Code:
#!/bin/bash
length=$ ## Int length of string1
noletter=1
cnt=1
x=0
while [ $noletter -le $length ]
do
set -- $( echo $string1 | cut -c${cnt} )
string1array[$x]=$1
noletter=$(( noletter + 1 ))
cnt=$(( cnt + 1 ))
x=$(( $x + 1 ))
done
Code:
y=0
length = ##integer length of word
echo "Array is: "
while [ $y -lt $length ]
do
echo -ne "${string1array[$y]} "
y=$(( y + 1 ))
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|