how to move files in a loop?
Hi
How can I move more than one files to new location? Assume: ls -lrt |more -rw-rw---- 1 oracle dba 21906432 Feb 14 19:00 ab_0000001458_1.arc -rw-rw---- 1 oracle dba 32099328 Feb 15 07:00 ab_0000001459_1.arc -rw-rw---- 1 oracle dba 8423424 Feb 15 19:00 ab_0000001460_1.arc ... ... ... -rw-rw---- 1 oracle dba 8423424 Feb 15 19:00 ab_0000001500_1.arc ... I want to move the files between 1458 and 1500 to new location. I tried this but didnt work. for file in *{1458..1500}_*; do mv "$file" /ora/archives done |
Basically like this
Code:
for num in `seq 1458 1500` |
Code:
mv ab_*{1458..1460}*arc /destination |
Quote:
|
Hi
I tried it in current directory but error returned mv ab_*{1450..1512}*arc /ora/archives ab_*{1450..1512}*arc: cannot access: No such file or directory |
Quote:
|
@OP, then in those sequences, some of them is missing in your file names. (my guess)
|
no
I just checked them, I even tried for two file, still same error message. Hp Unix |
Quote:
Code:
mv ab_000000{1450..1512}.arc /ora/archives |
Again the same:
ab_*{1450..1452}*arc: cannot access: No such file or directory. By the way: ls -lrt -rw-rw---- 1 oracle dba 1564672 Feb 12 20:42 ab_0000001451_1.arc -rw-rw---- 1 oracle dba 1675264 Feb 12 23:24 ab_0000001452_1.arc -rw-rw---- 1 oracle dba 28751872 Feb 13 07:00 ab_0000001453_1.arc -rw-rw---- 1 oracle dba 75577344 Feb 13 19:01 ab_0000001454_1.arc .. .. .. .. .. .. |
Are you using bash? And is brace expansion enabled as well as pathname expansion? What do you see when you do:
Code:
echo ab_000000????*.arc |
Silently editing your original post to change the filenames you listed is a little on the disingenuous side. You've effectively made everyones responses to you look wrong, when based on the information you originally provided, they weren't. Making people who take the time to try and help you look stupid is bad form.
|
You are right Gazl
I appreciate your help. I made a mistake. then I correct it, I am truly sorry, and even it doesnt help, I appreciate your help |
|
Quote:
@scofiled83, what is the output of Code:
echo $- |
All times are GMT -5. The time now is 10:54 AM. |