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 -->
  #6 (permalink)  
Old 07-06-2009
cbo0485 cbo0485 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 87
Quote:
Originally Posted by vidyadhar85 View Post
then use the basename only
Code:
basename "$filename" .BEFORE_DISASTER_RECOVERY
home> basename startServer.sh.BEFORE_DISASTER_RECOVERY .BEFORE_DISASTER_RECOVERY
startServer.sh
home>  basename startServerABC.BEFORE_DISASTER_RECOVERY .BEFORE_DISASTER_RECOVERY
startServerABC
I think you got my point...
This works perfectly inside my loop.

Thanks
Code:
for i in `find . -name "*.BEFORE_DISASTER_RECOVERY"`;do dir_name=`dirname $i`;file_name=`basename $i`;cd $dir_name;cp $file_name `basename $file_name .BEFORE_DISASTER_RECOVERY`;pwd;cd $BASE_DIR;done