![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| For loop using find with file name spaces | mronsman | UNIX for Dummies Questions & Answers | 3 | 09-12-2008 08:23 AM |
| Variable problem in for loop with if statement | ejdv | Shell Programming and Scripting | 6 | 06-17-2008 08:52 AM |
| For loop statement - catch error | lumdev | Shell Programming and Scripting | 4 | 09-20-2007 07:50 AM |
| if statement in a while loop | bobo | UNIX for Dummies Questions & Answers | 2 | 11-07-2006 12:38 PM |
| if statement in for loop of a string | Sniper Pixie | UNIX for Dummies Questions & Answers | 7 | 03-02-2006 07:28 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
For loop find statement file name manipulation
Code:
for i in `find . -name "*.BEFORE_DISASTER_RECOVERY"`;do dir_name=`dirname $i`;file_name=`basename $i`;cd $dir_name;mv $file_name (STUCK HERE) ;pwd;cd $BASE_DIR;done I'm sure it's something simple, but this is where I'm currently stuck. |
|
||||
|
Quote:
Anyways, I think you misunderstood or had a typo, I don't want to add that to my file, I want to remove it. I have files named: startServerABC.BEFORE_DISASTER_RECOVERY or startServer.sh.BEFORE_DISASTER_RECOVERY I need to remove the .BEFORE_DISASTER_RECOVERY from the file name, to be left with startServerABC or startServer.sh |
|
|||||
|
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 |
|
||||
|
Quote:
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 |
| Sponsored Links | ||
|
|