find command - some unusual usages

book

Article ID: 168138

calendar_today

Updated On:

Products

XOS

Issue/Introduction

The Linux command 'find' is well-known in itself, but rarely exploited to its full potential.N/A

Cause

Most Linux-using engineers will sometimes use the 'find' command to... well to find a file:

Here's a fairly typical example:
 
[[email protected] /]# find /tftpboot/sean_1/ -name lastlog
/tftpboot/sean_1/usr/bin/lastlog
/tftpboot/sean_1/var/log/lastlog
/tftpboot/sean_1/sean_common/usr/bin/lastlog
/tftpboot/sean_1/sean_common/var/log/lastlog

Yet 'find' can do so very much more! How about using it to find all files on a VAP member which have changed in the last 24-hours:

 
find /tftpboot/sean_1/ -type f -mtime 0

 
Or, slight change, to find which files have changed *today* (i.e. since midnight):
 
find /tftpboot/sean_1/ -daystart -type f -mtime 0

 
Just a couple of (potentially useful in their own right) illustrations. find can do a lot more than just find files by name...