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 -->
  #3 (permalink)  
Old 01-25-2008
KittyWu KittyWu is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 8
Hi,

you can do it without any function call by using the Pattern-matching operators (which are faster).

for instance:
me@host> BackupLocation='abc/dfg'
me@host> SubDir=${BackupLocation##*/}
me@host> echo ${SubDir}
dfg
me@host> BackupLocation=${BackupLocation}/${SubDir}$(date +%w)
me@host> echo ${BackupLocation}
abc/dfg/dfg5

(see 'KornShell/Pattern-matching Operators',
[Chapter 4] 4.3 String Operators)

Hope it helps,
Christophe