Unix newbie could use your help.
I'm using Solaris 10 and need to find all files, excluding all hidden files and directories. The ultimate goal is to put this in a script that will delete files 60+ days old on a server.
I tried:
find . ! ( -name '.*' -prune )
but it finds no files at all.
Any suggestions are appreciated.
I believe the problem is that you are excluding everything named ".*", and you are starting your search at "." (which matches your exclusion), so you are excluding everything. Also, I believe you are misusing the
-prune
flag (it's an action, like-print
, and so isn't necessarily useful as part of a negated expression). Try this:This explicitly includes '.' in the search, and then excludes everything else matching
.*
. If you know that your starting point doesn't include any dotfiles, you can simplify this a bit:This should work:
find . -name '[^.]*'
find . -type f -name '[^.]*'
find . -name '[^.]*' -mtime +59 | xargs rm -f