find(1) seems very un-unixy, but it's very powerful. Let's assume for
a minute that find didn't exist. How would you do the following:
1. execute a command for each file (find . -exec whatever {} \;)
2. find files that are > 8M
3. find files that are older than 20 days
4. find all files that are owned by 'joe' that also have execute
permissions for world
Obviously we can write scripts and complicated one liners, but
ultimately it seems as though for most of these things we'd have to
parse output (in some cases convert units) and in general do sucky
things (with the exception of maybe, 1, but ls -R's output isn't easy
to use here)
As a result, does it make sense (or do these already exist?) to have
some of the following:
walk - (implements find $1)
sizep - usage: sizep +Nunit -Nunit =Nunit file1 ..
agep - usage: agep +Nunit -Nunit =Nunit file1 ...
permp - usage: permp {+ | -}{a | u | g | o}{r | s | t | w | x | X | u
| g | o} file1 ...
ownerp - usage: ownp -g <group name> -u <username> file1 ...
All of these just print to stdout the names of the files that meet the
requirements, and all of them can read their file names from stdin if
- is given instead of files
So, to find all files in /etc modified within the last hour...
walk /etc | agep -1H -
Or,
walk /etc | xargs agep -1H
Thoughts? Pointers to tools that already do this?
Cheers,
Andrew
--
http://apgwoz.com
Received on Thu Dec 12 2013 - 20:32:03 CET