On 2014-04-27 18:30, Anton Aylward wrote:
On 04/27/2014 11:12 AM, Carlos E. R. wrote:
Mmm. I think you propose something instead of my 'while' loop above:
find $LISTADO_FIND_PRUNED -type f
Where $LISTADO_FIND_PRUNED is a file containing the list of paths to search?
In short, yes, but the $LISTADO_FIND_PRUNED is geenrated by 'find' as a subshell
find $(program that generates LISTADO_FIND_PRUNED) -type f
See the shell manual page for how to use embedded subshells. I make use of this facility quite a lot. Coprocessing offers a number of advantages over seperate sequential, although this isn't the best example of that.
I see. Interesting. That gave me an idea of another part of the script, but I failed:
cer@Telcontar:~> grep Bourne-Again "$(head -c 1000 bin/0_script_constructs | file -)" grep: /dev/stdin: Bourne-Again shell script, UTF-8 Unicode text executable: No such file or directory cer@Telcontar:~>
The intention here was for grep to locate the string "Bourne-Again" on the output text of the subshell. But it does not do that, it interprets it as the file(s) to look inside. This part works:
cer@Telcontar:~> echo "$(head -c 1000 bin/0_script_constructs | file -)" /dev/stdin: Bourne-Again shell script, UTF-8 Unicode text executable cer@Telcontar:~>
The intention is simply to trigger an 'if' selector depending on whether it is a script or not (grep produces appropriate exit codes). I have this working instead with another method, which is a modification from an answer from a thread a year ago (Re: Re: [opensuse] Searching for string in many files [Was: 12.3 + ntfs + ext4 + USB3 + different copying speeds])
while read FILES ; do TIPO=`head -c 1000 "$FILES" | file - | awk '/Bourne-Again/{print $2}'` if [ "$TIPO" = "Bourne-Again" ]; then echo "$FILES" >> $LISTADO_SCRIPTS fi done < $LISTADO_FIND
which works perfectly, but I was attempting to speed it up a bit by using grep instead of awk. Of course, 'test' would be better, but it only matches on full strings, not substrings. Ie, there is no: test string -inside-string string which as a bash built-in would be the fastest one ([ -eq ])
I was hooping 'find' to have an "--exclude-path", but I can't see such a thing in the large manual.
Its there it just isn't called "--exclude-path".
Ah. I thought it might be so. ...
So you could EITHER -prune or you could say "not this pattern and not this pattern and not this pattern"
RTFM for further details http://www.theunixschool.com/2012/07/find-command-15-examples-to-exclude.htm...
But this seems to be exactly what you want http://www.liamdelahunty.com/tips/linux_find_exclude_multiple_directories.ph...
It is indeed. I'm using now: find "$DONDE" -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 which is exactly what I wanted :-) -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)