The UNIX and Linux Forums  

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



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
Compare multiple fields in file1 to file2 and print line and next line gillesc_mac Shell Programming and Scripting 7 03-16-2009 06:26 AM
Reading a file line by line and processing for each line sagarparadkar Shell Programming and Scripting 6 03-02-2009 11:59 AM
I need suggestion on problem read a file line by line and do stuff madi3d8 Shell Programming and Scripting 3 01-15-2009 11:33 AM
Deleting Characters at specific position in a line if the line is certain length Cailet Shell Programming and Scripting 10 12-17-2008 02:41 PM
how to delete text from line starting pattern1 up to line before pattern2? repudi8or Shell Programming and Scripting 5 04-15-2008 10:25 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-18-2009
Trump Trump is offline
Registered User
  
 

Join Date: Mar 2009
Location: Russia
Posts: 23
cut in line

hi
how can i get from
Komendant st. house 50 ex. 1 fl. 1000 to > Kome.50.2.1000
Elsestreet house 51 ex. 2 fl. 11 to > Else.51.2.11
???

Last edited by Trump; 03-18-2009 at 12:52 PM..
  #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,378
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

  #3 (permalink)  
Old 03-18-2009
Trump Trump is offline
Registered User
  
 

Join Date: Mar 2009
Location: Russia
Posts: 23
Quote:
Originally Posted by cfajohnson View Post

Where did you get "28"?


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

thnx for script ,
can you tell me how to set first four characters to upper case?

Last edited by Trump; 03-18-2009 at 01:27 PM..
  #4 (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,378
Quote:
Originally Posted by Trump View Post
thnx for script ,
can you tell me how to set first four characters to upper case?


Code:
a=$( printf "%s\n" "$a" | tr [:lower:] [:upper:] )

In ksh:


Code:
typeset -u a

In bash4.0:


Code:
a=${a^^}

  #5 (permalink)  
Old 03-18-2009
Trump Trump is offline
Registered User
  
 

Join Date: Mar 2009
Location: Russia
Posts: 23
Excuse, was mistaken at input
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0