loop move files up one directory level
I am trying to recursively move files with a certain pattern in some directories up one level in their path and then remove them from the original location.
Quote:
Osio P.S. Most of the code above is inspired by CroMagnon's post http://www.linuxquestions.org/questi...43#post1217543, although in the IFS bit I really don't know what I'm doing :) |
I am not 100% sure what you are doing, but have you considered doing: "$i/../" for your upper level? Or something along those lines. if $i is "hello/world", then $i/.. is "hello/". Is that what you wanted?
|
Hi.
How about '$i/..' Dave Edit. Ack. Too late by far. |
I define a variable with a pattern. Then I want to find files with that pattern in listed directories of a given one. Once found, I simply want to move those files from those directories up to the given directory.
Matir, I'm sorry but I don't understand. I've tried defining variables like Quote:
Quote:
Quote:
|
You'll have to deal with each file individually. At the moment, you've got all the paths in one variable.
Something like: Code:
for go in "`find . -type f`" Dave |
Then the 'mv $i/$j' wouldn't work either, as it would only append $j to the last item in $i. You will need to split it.
|
find . | grep pattern |
while read file;do echo mv "$file" to_here done |
Thanks guys; the ${var}/.. works beautifully.
|
Glad it worked out for you. Hope your whole project goes that smoothly. :)
|
All times are GMT -5. The time now is 01:09 AM. |