0

I have to come up with a find command to find certain files in a directory. The directory has sub directories and sym-links to other directories. If I use the following find command it ignores the sym-links:

find $dir/ -name '*.out' -size 0 -mtime +0 

The following follows the sym-links:

find -L $dir/ -name '*.out' -size 0 -mtime +0 2

I am trying to figure out a way to use -prune and additional -name flags to omit certain elements from the directory. I need something that works on both Linux and AIX.

Some commands I've tried:

find -L . ( -name dest ) -prune -o -name "*.out"
find -L $dir -name *.out ( ! -name "dest" -prune )
3
  • Can you post what you tried with -prune? Commented Sep 14, 2017 at 14:04
  • Did you read documentation of find ? BTW you could compile and use GNU findutils on your AIX system Commented Sep 14, 2017 at 14:04
  • @h3rrmiller Some commands that i tried without success <br/> find -L . ( -name dest ) -prune -o -name "*.out" <br/> find -L $dir -name *.out ( ! -name "dest" -prune ) Commented Sep 14, 2017 at 14:35

1 Answer 1

2

Without an "action" (like -print), find will print out each file it visits. This behavior is why find -L . ( -name dest ) -prune -o -name "*.out" still shows the files you are pruning. find has to visit the file before it can evaluate the conditions you provided.

Adding the -print action to the end of your find command should do the trick.

find -L . -name dest -prune -o -name "*.out" -print
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.