[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] safty of my script
From: |
Dan Douglas |
Subject: |
Re: [Help-bash] safty of my script |
Date: |
Sun, 09 Mar 2014 15:14:12 -0500 |
User-agent: |
KMail/4.12.3 (Linux/3.13.2-pf+; KDE/4.12.3; x86_64; ; ) |
On Sunday, March 09, 2014 07:45:42 PM Martin wrote:
> Ok, I just use that, maybe that is more for compatibility on different
> systems...
Yeah you can ignore that. I only included that code because I already had it
written, and 1 second precision isn't that great for this kind of thing. It
basically buys letting you do float comparisons in a few shells without
throwing errors in others.
> About this block above, for me it seems not to work.
> ...but find . -type f -name "*new*" does not find anything.
I was making an assumption that you wanted files matching that pattern. The
point being that you should not use grep to filter files matched by find. It
sounds like what you actually want is either:
a) for find to not descend into directories that are not named "new".
b) to match only regular files that have some parent directory named "new".
"b" is pretty easy, just use -path. Code will be:
find . -type f -path '*/new/*' -printf ...
"a" is harder (I had to think about it). You'd have to use -prune. In that case
that part of the code would end up looking something like this:
...
find . -type d -path './*/*' ! -name new -prune -o -type f
-printf '%Ts\0%p\0' |
while IFS= read -rd '' mTime && IFS= read -rd ''
fileName; do
(( mTime <= startTime )) && continue
mv -f -- "$fileName" "$tmp"
spamc <"$tmp" >"$fileName"
done
rm -f -- "$tmp"
...
--
Dan Douglas