
03-18-2009
|
|
Shell programmer, author
|
|
|
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
|
|
Quote:
Originally Posted by Trump
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
|