Solaris – find

August 18th, 2009

# cd /work && find . -type d -exec ls {} \;

find the approximate number of files/inodes
#find /work -xdev -exec ls -id {} + | cut -c-11 | sort -u | wc -l

find 20 larges files over 90 days old.

# find /work/ftp/local -mtime +90 -print -type f -exec ls -la {} \; | sort -r -n -k 5,5 | head -20

remove files older that 60 days.
# find . -mtime +60 -exec rm -f {} \;

find largest files within last 30 days
# find /work/ftp/pub -mtime -30 -type f -exec ls -la {} \; | sort -r -n -k 5,5 | head -40

list size of directory in MegaBytes
# ls -lR | awk ‘{total +=$5};END {print “Total size: ” total/1024/1024 “MB” }’

find the 20 largest files
# find /tmp -type f -follow -print | xargs ls -l | sort -r -n -k 5,5 | head -20

look recusivly down for any file >= to 1meg then list path

#find . -size 1000000c -lsĀ  #

# find . -mtime -1 -type f -print
finds all files that have been modified within the last 24 hours

# find Members/ -type f -print0 | xargs -0 grep “examplestring”

find files by user

# find . -name SCCS -prune -o -print

In the above example the find command finds all files in the Members
directory each file that is found is then searched using grep for
the text “examplestring”

Fast alternative to cp -pr
# find . -depth | cpio -pdmv /path/tobe/copied

To find files owned by a user, please use the following command
# find . -user <USERLOGIN ID> -a -type f -print

Find SUID and SGID programs
# find . \( \( -perm -04000 -a -perm +011 \) -o \( -perm -02000 -a -perm +01 \) \) -print

Trackback URI | Comments RSS

Leave a Reply

For spam filtering purposes, please copy the number 5576 to the field below: