[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to write a script that recursively check files in a directory with md5sum



On Thu, 15 Jul 2004, Matthias Czapla wrote:

I have no idea, but I use something like this to recurse down a tree and
do something with every file:

#!/bin/bash
for i in `find -type f`
do
     whatever you wan't to do, just use $i instead of the filename.
done

This will not work if any component of a path contains spaces. If
this is not the case then there is nothing wrong with this approach,
IMHO.

If you just add the following statement, then the above loop will work fine:
IFS='[return]
'

That is, set IFS to be a carriage return and nothing else. That will cause 'for' to only split on carriage returns, which works just dandy. And generally much more readable than find.

--
I was an only child...  eventually.  -- Stephen Wright
---------------------------------------------------------------------
Luke Kanies | http://abstractive.org | http://reductiveconsulting.com



Reply to: