The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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




Thread: cut in line
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-18-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by Trump View Post
hi
how can i get from
Komendant st. house 50 ex. 1 fl. 1000 to > Kome.28.2.1000

Where did you get "28"?
Quote:
Elsestreet house 51 ex. 2 fl. 11 to > Else.51.2.11
???

Code:
for string in "Komendant st. house 50 ex. 1 fl. 1000" \
              "Elsestreet house 51 ex. 2 fl. 11"
do
  a=${string%"${string#????}"} ## put first four characters in $a

  set -f
  set -- $string
  set +f
  shift $(( $# - 5 ))

  echo $a.$1.$3.$5
done