iSteve Posted January 7, 2021 Posted January 7, 2021 Hi all, I need a script to look in to a folder and delete all it's contents apart from two named folders. This is running on Mac OS, so needs to be Unix/Linux type script, not Windows. I am using the following: shopt -s extglob cd /Users rm -rf !(administrator) ...which removes everything apart from a folder called "administrator", however I want it to delete everything apart from "administrator" and "Shared" how do I structure the syntax to define a second exclusion? I'm also open to any alternative methods... Thanks
bald_pig Posted January 7, 2021 Posted January 7, 2021 Hi all, I need a script to look in to a folder and delete all it's contents apart from two named folders. This is running on Mac OS, so needs to be Unix/Linux type script, not Windows. I am using the following: shopt -s extglob cd /Users rm -rf !(administrator) ...which removes everything apart from a folder called "administrator", however I want it to delete everything apart from "administrator" and "Shared" how do I structure the syntax to define a second exclusion? I'm also open to any alternative methods... Thanks shopt -s extglob cd /Users rm -rf !(administrator[color=#008000]|shared[/color]) That should do the trick if it's using standard regex. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now