HOW TO WRITE A SHELL SCRIPT TO DISSECT FILENAME FROM DIRECTORY PATH

ITEM: RTA000027265



                                                                                
                                                                                
                                                                                
  Question:                                                                     
                                                                                
  I am interested in writing a shell script that will work in both              
  Bourne and korn shells that will parse out the                                
  filename from the directory path.  In other words, I would like to            
  perform the following function:                                               
                                                                                
  /xxx =  /usr/john/data.fil                                                    
---------- ---------- ---------- --------- ---------- ----------                
Response:                                                                       
                                                                               
  You can use the basename command to retrieve the filename from                
  a path.  (The dirname command will retrieve the directory from                
  a path.)  For example:                                                        
                                                                                
         basename /usr/john/data.fil                                            
                                                                                
  will return "data.fil."                                                       
                                                                                
  It is also possible to use awk to retrieve the filename.                      
  For example:                                                                  
                                                                                
       echo "/usr/john/data.fil"/awk '(FS=/";print $NF)'                        
                                                                                
  will also retrun "data.fil"                                                  
---------- ---------- ---------- --------- ---------- ----------                
                                                                                
                                                                                
This item was created from library item Q609805      2VZQQ                      
                                                                                
Additional search words:                                                        
AWK BASENAME CUSTORG DCF DIRECTORY DIRNAME DISSECT FILENAME IRQ                 
IRQ6000 IX OCT92 OZNEW PATH SCRIPT SHELL STATE2 WRITE WRITER WRITING            
2VZQQ                                                                           
                                                                                
                                                                                
                                                                                
                                                                                
                                                                               


WWQA: ITEM: RTA000027265 ITEM: RTA000027265
Dated: 01/1995 Category: IRQ6000
This HTML file was generated 99/06/24~12:43:09
Comments or suggestions? Contact us