[SOLVED] How to mv while keeping matching sub-directories
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You could create a test area with same dir file layout and a few small files to test, but I don't think(?) mv is that smart ie multi-levels of wildcards.
I'd use a script with find cmd, and test first eg in a test area or use 'echo' to echo out what it would have done instead of doing the actual mv.
Thanks
I didn't know rsync, that looks great (but not for what I wanted of course)
So it's some kind of MySQL replication concept, but for files?
But the thing is, I was trying to find a way to make a real MOVE, not copy + rm.
Copy + rm is very long for these files, and makes a problem of confidentiality since I'm gonna have to shred everything at the end...
But my program worked
Perl worth it lleb, it's an awesome language. There is nothing you cannot do in perl.
If the destination directory is on the same filesystem, the files directory entry is moved. If the destination is on a different filesystem, then the `mv' command does a copy & delete. If confidentiality is important, you could change the one liner adding && shred <pathname> to the end.
the nice thing about rsync (remote Synchronize) is that it is extremely light on the system, does compression during the move as well as encryption for security.
sadly the rm is very heavy on the system, but not as heavy as mv.
i just have not had time to learn perl. wanted to learn C first. im only a new programmer as in less then 4-6 months with BASH. my next goal is to learn C, then work on perl.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.