Friday, January 23, 2009

HP-UX find

Q : Is there a way to run "find" so it reports all files/subdirs under a directory that are over X days old without transposing through all the subdirs?

example
under /X
/X/Y/Z
/X/A/B/C/D
/X/A/E/I/O/U

I would like it to report back only if Y and A have a date stamp older then 30 days.

A : find * -type d -prune -mtime +60
EXAMPLES (HP-UX man pages)
Search the two directories /example and /new/example for files
containing the string Where are you and print the names of the files:

find /example /new/example -exec grep -l 'Where are you' {} \;

Remove all files named a.out or *.o that have not been accessed for a
week:
find / \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} \;

Note that the spaces delimiting the escaped parentheses are
required.

Print the names of all files in /bin that are context-dependent; that
is, hidden directories:
find /bin -type H -print

Print the names of all files on this machine. Avoid walking nfs
directories while still printing the nfs mount points:

find / -fsonly hfs -print

Copy the entire file system to a disk mounted on /Disk, avoiding the
recursive copy problem. Both commands are equivalent (note the use of
-path instead of -name):
cd /; find . ! -path ./Disk -only -print | cpio -pdxm /Disk
cd /; find . -path ./Disk -prune -o -print | cpio -pdxm /Disk

Copy the root disk to a disk mounted on /Disk, skipping all mounted
file systems below /. Note that -xdev does not cause / to be skipped,
even though it is a mount point. This is because / is the starting
point and -xdev only affects entries below starting points.
More on man pages from HP-UX...kampai!

No comments:

Post a Comment