The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using Rename to move files snufse UNIX for Dummies Questions & Answers 1 04-09-2008 09:57 AM
how to move files monicasgupta Shell Programming and Scripting 1 03-14-2008 01:53 PM
How to move all files except one? Kim Walisch Shell Programming and Scripting 4 11-02-2007 02:00 PM
move files uniksbro UNIX for Advanced & Expert Users 4 07-31-2007 08:42 AM
move files mta UNIX for Dummies Questions & Answers 2 01-16-2004 10:22 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-30-2005
ust ust is offline
Registered User
 

Join Date: Feb 2005
Posts: 95
move files

I want to move files ( about 1000 files ) from /tmp/edp1 to /tmp/edp2, all files are no extension, I want to add .txt to the end of all files ( eg. the original file name is oracl , the new file name should be oracl.txt ) , could suggest what can I do ? thx
Reply With Quote
Forum Sponsor
  #2  
Old 06-30-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
Code:
for file in `ls /tmp/edp1/`
do
mv $file /tmp/edp2/$file.txt
done
Reply With Quote
  #3  
Old 07-02-2005
ust ust is offline
Registered User
 

Join Date: Feb 2005
Posts: 95
thx reply,
I tried it , but it pop the below message , could suggest what is wrong ? thx

mv: cannot stat `orictmd': No such file or directory
Reply With Quote
  #4  
Old 07-02-2005
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
You're not in the correct working directory.

Just cd /tmp/edp1 before starting the for loop.

The code below would be slightly faster (can be made even faster with shell builtins for the mv, but anyway....)

cd /tmp/edp1
ls | while read file; do
mv $file /tmp/edp2/$file.txt
done

Cheers
ZB
Reply With Quote
  #5  
Old 07-03-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
Quote:
Originally Posted by zazzybob
The code below would be slightly faster (can be made even faster with shell builtins for the mv, but anyway....)
There is a shell builtin for mv ?

What is it ? Where is it documented ?

I checked the man pages for bash under the section SHELL BUILTIN COMMANDS.


-vino
Reply With Quote
  #6  
Old 07-03-2005
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
I had some stuff in my post that I removed (involving the use of another command within backticks within the mv - that's where I was talking about shell builtins) before posting and I forgot to remove that comment. Whooops....

That'll teach me to be more careful when making edits

Cheers
ZB
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0