LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   find command - multiple direcories (http://www.linuxquestions.org/questions/linux-general-1/find-command-multiple-direcories-477369/)

ygloo 08-25-2006 03:33 PM

find command - multiple direcories
 
how to ignore three dirs at once:
/dev /proc /sys
how to add 2 more here??
find / -cmin -20 -path '/proc' -prune -o -print

:scratch:

dombrowsky 08-25-2006 04:07 PM

I always have to try three or four times in order to get all the find options to work correctly, but here's my first guess:

Code:

find / \( -name /dev -prune -o -name /proc -prune -o -name /sys -prune  \) -o \( -cmin -20 -a -print \)
The parentheses might not be needed, but I think they are.

BTW, the default operation between find(1) commands is "and" (-a). This means that there is an implied "-a" between "-name foo" and "-prune". Find(1) can be quite annoying. Read the man page and do plenty of test cases.

ygloo 08-25-2006 04:19 PM

i get confused how to mix the options...

changed "-name" with "-path"
...and it works!

find / \( -path /dev -prune -o -path /proc -prune -o -path /sys -prune \) -o \( -cmin -20 -a -print \)

ygloo 08-25-2006 04:44 PM

used what you told me in a script to find files changed or modified :
#!/bin/bash


Uptime=$( less /proc/uptime | awk '{ print $1 }')
UpSeconds=${Uptime%.*}
UpMinutes=$( echo $(( $UpSeconds / 60 )) )

Sort ()
{
awk '{ print $3, $5, $6, $8, $9, $10, "\t " $11 }'
}

echo
echo i - $UpMinutes mins since boot
echoc "skipping dev,proc and sys directories" green

echo
echo "how far to look back ??"

read

{
echo
echoc "_______________________________________ created:" green
find / \( -path /dev -prune -o -path /proc -prune -o -path /sys -prune \) -o \( -cmin -"$REPLY" -type f -ls \) | Sort

echo
echoc "_______________________________________ modified:" green
find / \( -path /dev -prune -o -path /proc -prune -o -path /sys -prune \) -o \( -mmin -"$REPLY" -type f -ls \) | Sort
echo
} > list


All times are GMT -5. The time now is 10:56 AM.