If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > URGENT...help with mv

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-17-04, 14:58
saccskiz saccskiz is offline
Registered User
 
Join Date: Feb 2004
Posts: 143
URGENT...help with mv

Hi,
I have files in my directory which is named like

aaa.sh_save
bbb.sh_save
ccc.sh_save
ddd.ctl_save ...( plus there are many more like this.)


I wanted to rename all of these scripts to ...

aaa.sh
bbb.sh
ccc.sh
ddd.ctl


In other words, the _save should be removed from the file names. How do I acheive this ? This should also affect all files lying in the sub-directories too.... from my current directory it should change all files plus all sub-direcotory files too...
Thanks
Reply With Quote
  #2 (permalink)  
Old 05-17-04, 16:21
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
#!/bin/ksh
find . -name '*_save' | while read file
do
mv $file ${file%%_save}
done;
Reply With Quote
  #3 (permalink)  
Old 05-17-04, 16:49
saccskiz saccskiz is offline
Registered User
 
Join Date: Feb 2004
Posts: 143
Thanks a lot...worked great...

Can I also ask you a question on this solution. How can I find help on the meaning of %% (just for my fyi to know how it does things and other options)..
Reply With Quote
  #4 (permalink)  
Old 05-17-04, 16:53
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
do 'man ksh' and search for 'Parameter Expansion'
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On