0

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.

3 Answers3

2

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:

find . \( -name '.*' \! -name '.' -prune \) -o -print

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:

find * \( -name '.*' -prune \) -o -print
larsks
  • 47,453
0

This should work:

find * | grep -v /\\.
jlliagre
  • 9,031
0

need to find all files excluding all hidden (files and directories).

find . -name '[^.]*'

excluding all (hidden files) and directories.

find . -type f -name '[^.]*'

The ultimate goal is to put this in a script that will delete files 60+ days old on a server

find . -name '[^.]*' -mtime +59 | xargs rm -f