The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 11-12-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
With zsh:

Code:
zsh-4.3.4% s="5.2.314"
zsh-4.3.4% a=(${(s:.:)s})
zsh-4.3.4% print $a[1]
5
zsh-4.3.4% print $a[3]
314

With ksh93/bash:

Code:
bash 3.2.25(1)$ s="5.2.314"
bash 3.2.25(1)$ set -- ${s//./ }
bash 3.2.25(1)$ echo $1
5
bash 3.2.25(1)$ echo $3
314