![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
for file in `ls /tmp/edp1/` do mv $file /tmp/edp2/$file.txt done |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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 |
|
#5
|
||||
|
||||
|
Quote:
What is it ? Where is it documented ? I checked the man pages for bash under the section SHELL BUILTIN COMMANDS. -vino |
|
#6
|
||||
|
||||
|
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 |
||||
| Google The UNIX and Linux Forums |