0
echo "How many days old are the branches you want to delete"
echo -n "[Branches age]: "
read userDays
echo "Deleting branchs older than $userDays day old:"
sudo find $FOCUS_HOME -maxdepth 1 -mtime +$userDays -printf '%f\n' -exec rm -rf {} \
echo "Done! All branchs $userDays days old are removed"

I have this simple script shown above that will delete my branches that are kept on my computer after whatever days I put in, that will look at my last time I modified that branch, avoiding me from deleting a branch I might have recently been working on even though its old. I wanted to add an exlusion to this. Basically this will usually return something like:

austins-123456

and then launch an rm -rf on that folder. But I want to have it exclude a certain string:

trunk

1 Answer 1

1

Maybe :

sudo find $FOCUS_HOME -maxdepth 1 -mtime +$userDays ! -name 'trunk' -printf '- %f\n' -exec rm -rf {} \

? :)

Check the -path switch too.

If it's for git or svn, maybe there's a more proper solution

Sign up to request clarification or add additional context in comments.

3 Comments

Looks like that worked however. sudo find $FOCUS_HOME -maxdepth 1 -mtime +$userDays ! -name 'trunk' -printf '%f\n' -exec rm -rf {} \ Otherwise you get: find: warning: you have specified the -maxdepth option after a non-option argument !, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.
How would I actually add more than 1 string, Say I wanted to avoid trunk, austins-123, austins-321. Also its SVN however I dont want to actually remove the svn path or anything just from my local computer I want it to stay in the repo just not taking space on my computer.. lol
Check -a and -o switchs from the man page. Maybe need parenthesis regroupment

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.