I have a linux issue that I would like some help with...
I have an application that creates directories for me. I'd like to write a script that looks at these directories, checks to see whether the directory starts with a certain string of characters, if it does, leave it alone, if it doesn't then move it...
So, from a logical stance:
If directoryname begins with "ABC" then do nothing
else
move folder to sharedrive
This script will go in the cron.hourly folder so it runs automatically for me.
Any help is greatly appreciated!!!
find . -mindepth 1 -maxdepth 1 -type d ! -name 'ABC*' -exec mv -i {} ./dest \;
If you can identify a simple pattern for the directories you don't want to move, you might even be able to use bash's extglob setting:
shopt -s extglob
mv !(ABC)*/ ./dest/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With