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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 06-28-2006
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
Here's one hint:
Using recent version of ksh or bash, you can do this:
Code:
fullname="/home/ 572011 O4MP ORDS 188406 V01 DT 20060608154548.txt"
file="${fullname##*/}"
read _ _ _ dir _ <<<$file
echo $dir
If you have an older version of either ksh or bash, the following works, but is not as aesthitically pleasing (to me )
Code:
fullname="/home/ 572011 O4MP ORDS 188406 V01 DT 20060608154548.txt"
file="${fullname##*/}"
echo $file| read _ _ _ dir _
echo $dir
Please post back if you run into further problems implementing this...