The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 01-05-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,960

Code:
# !/opt/third-party/bin/zsh
                                                                                 
str="A12B3456CD78"
                                                                                 
only_num=$(echo $str | tr '[A-Za-z]' ' ' | awk '{print $NF}')
only_alpha=$(echo $str | tr '[0-9]' ' ' | awk '{print $NF}')
echo $str $only_num $only_alpha | awk '{ print (substr ($0,0,length($1) - ( length($2) + length($3) ))), "\n", $2, "\n", $3 }'
                                                                                 
exit 0