On Thu, 25 Apr 2013, Paul graf wrote:

> I would like to study the 'man find' command with another person 's who 
> are interested in the command. Finding files that have been modified and 
> sent to folders on a certain date in time. The 'find' command is very 
> powerful I believe. I would enjoy a workshop and to listen and be able 
> to talk with others 'such as yourself'. I am sorry to not send my 
> message clearly I have no formal education.

First -- for finding files on the system, it is often a lot faster and 
easier to use "locate".  Check that out.  I usually capture the output 
from locate using less because sometimes there are a lot more lines than 
you would think because every path that includes a string will be show.

locate whatever | less

Then I'll use grep commands to limit the results:

locate -i whatever | grep -i tclug | less

The -i option makes the command case insensitive.


Here is something cool and useful that I do with find.  Suppose I have a 
directory "foo" and that has a directory tree inside it with thousands of 
files.  I want to copy it to some other machine, remote_host, and after it 
arrives, I want to check that it's all there and unchanged.  First I use 
find with md5sum to make a file of md5 hashes:

find foo -type f -print0 | xargs -0 md5sum > foo_md5sums.txt &

The "-type f" option causes find to list only regular files, then 
"-print0" uses null characters instead of newlines to delimit the files in 
the output list, but xargs with "-0" option takes that kind of list as 
input.  The reason for using the nulls instead of newlines is that it 
allows xargs to handle properly filenames with spaces.  Next I transfer 
the file:

scp -rp foo foo_md5sums.txt remote_host:.

That's using scp, but there are other ways one might copy files across a 
network, or you might even use an external drive, flash drive or DVD to 
send files somewhere.  Then go to the other machine...

ssh -X remote_host

...and run this check:

md5sum --check foo_md5sums.txt | grep -v OK$

The --check option uses the md5sums file as input and checks every file 
listed, which includes every file in the foo directory tree.  The grep 
command at the end is just deleting all the lines that say the file was 
OK.  If a file was not present or it didn't match, you will see some 
output.

Mike