![]() |
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 |
| Reading a file using sh with spaces in filename | jekl5 | Shell Programming and Scripting | 4 | 02-29-2008 10:18 AM |
| How to print arguments along with spaces using awk | jisha | Shell Programming and Scripting | 8 | 01-17-2008 01:43 AM |
| Reading a line including spaces | aksarben | UNIX for Dummies Questions & Answers | 1 | 09-19-2007 07:39 PM |
| Bash: Reading 2 arguments from a command line | Vozx | Shell Programming and Scripting | 0 | 12-08-2005 05:23 PM |
| Reading runtime arguments from a file | Sabari Nath S | UNIX for Dummies Questions & Answers | 4 | 08-24-2005 09:38 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Yes I am using the while loop for other purpases
Im afraid its still not working, if i type in "5 * 5" and then print out all array elements i get element 0 - "5" element 1 - "file 1 in directory" element 2 - "file 2 in directory" element n-1 - "file n in directory" element n - "5" Calypso |
|
||||
|
Right i see.
So you need to store anything including any character in an array or do you want to throw away anything other than say digits or numbers? What you need to start doing is checking the contents of $element before assigning it. What is a fuller scope of what you're trying to do then i may be able to help further ![]() |
|
||||
|
The following does work in bash in cygwin (the only place I have a bash shell to test)
and it's the same code as CFA Johnson's, except I'm printing the [1] element as that is the "*" which seems to be giving you problems. I'm not getting any problems this way. Code:
read input
set -f
oldIFS="$IFS"
IFS=' ' # space
array=( $input )
echo ${array[1]}
IFS="$oldIFS"
Code:
./test.sh # invoke script 5 * 5 # user input * # output of the echo command |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|