On 2014-04-27 22:16, Bernhard Voelker wrote:
On 04/27/2014 08:54 PM, Carlos E. R. wrote:
a) The test for "regular file" is needed, because the find, despite using "find "$DONDE" -type f ..." finds some directories, and thus I get some errors later:
head: error reading ‘/var/run/vmblock-fuse/dev’: Invalid argument
Very unlikely - there's something wrong in $LISTADO_FIND. However it was produced ... it contains directories.
It does indeed, I know. Very few, but some. But the one above (‘/var/run/vmblock-fuse/dev’) is a regular file, but zero bytes. I already added a check for that one: if [ -f "$FILES" -a -s "$FILES" ]; then which I have not tested yet because the script has been running for some time and I do not want to stop it again, unless I hit another big error. The "find" command I'm running now is this: find "/" -type f \ -prune -o -path '/var/spool/news' \ -prune -o -path '/var/run/udev/links' \ -prune -o -path '/var/run/user' \ -prune -o -path '/var/run/systemd' \ -prune -o -path '/var/lib/ntp/proc' \ -prune -o -path '/proc' \ -prune -o -path '/run/udev/links' \ > $LISTADO_FIND And the directories it appears to find are: ‘/var/run/user’ ‘/var/run/systemd’ ‘/var/run/udev/links’ ‘/var/spool/news’ ‘/var/lib/ntp/proc’ ‘/proc’ That is, it finds exactly those I tell it avoid. Everything inside those paths are skipped, but not the parents. It is not a big problem, I could just ignore the errors, because it would be faster that testing for them.
b) The use of:
head -c 1000 "$FILES" | file -
instead of directly:
file "$FILES"
is because "file" takes an awful amount CPU time to find out the types of all the files I feed it with, some of them huge (several gigabytes).
Maybe:
find ... -size -100k ,,,
assuming that shell script are usually smaller than 100k (okay, java shell installers are bigger, of course).
Yes, that would work, too. Interesting... Ah, you mean those big scripts with the compressed data tagged behind. Java installers, typically. No big deal... I'm not interested in them. I could do both things: tell "find" to limit itself to a certain size, and then also use "head". And also explore if I can tell find to skip non-regular files, and empty files too (Self-RTFM-again). -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)