![]() |
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 |
| extract numbers from a word | systemali | Shell Programming and Scripting | 14 | 03-30-2009 03:47 AM |
| can array store float point numbers | naree | SUN Solaris | 1 | 03-05-2008 06:59 AM |
| How to store the data retrived by a select query into variables? | jisha | Shell Programming and Scripting | 12 | 01-17-2008 11:45 PM |
| extract from string variable into new variables | Sniper Pixie | UNIX for Dummies Questions & Answers | 2 | 03-03-2006 10:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hi All,
Is it possible in Unix shell script to extract numbers from a string containing ".", such as; 5.2.314 And store in variables so; var1 = 5 var2 = 2 var3 = 314 Thanks in advance for any help anyone can provide dave |
|
||||
|
More rustic, more complicated, but running anywere I think
:Code:
#!/bin/ksh
a="5.2.314"
i=1
while [ "$a" != "" ]
do
x[$i]=$(echo $a | cut -d. -f1)
typeset x$i=${x[$i]}
((i=i+1))
a=$(echo $a | cut -s -d. -f2-)
done
echo "x1=$x1, x2=$x2, x3=$x3"
|
|
||||
|
Thank you very much everybody for your help!
|
| Sponsored Links | ||
|
|