[ILUG] find regex question

Padraig Brady padraig at antefacto.com
Wed Jun 19 11:54:42 IST 2002


Nice post!

Brian Foster wrote:
>   | Date: Tue, 18 Jun 2002 17:14:07 +0100
>   | From: Padraig Brady <padraig at antefacto.com>
>   |[ ... ]
>   | yuk. Why put regex in find?
>   | How about piping output of find to grep -E '[^/]*/[-0-9A-Z]{36}\.'
> 
>  because it's a powerful selection criteria?
>  e.g., whilst you can pipe to `grep' to implement `And' conditions
>  (e.g., is a directory And whose name matches the RE); it is much
>  harder to do `Or' (e.g., is a directories Or whose name matches).
>    having said that, `-exec sh -c "echo -E '{}' | grep -q ..." \;'
>    could be used to do `Or' albeit at the cost of opaqueness (plus
>    the usual newline-in-filename bugbear, see below) ....

agreed.

>  because it closes a security hole?
>  files whose names contain a newline (e.g.) make writing a 100%
>  reliable pipe-to-`grep' very difficult, perhaps impossible!
>    whilst GNU `find' does have `-print0', I am unaware of any
>    corresponding _input_ option for any `grep'.  hence, AFAIK,
>    this hole cannot be closed when using pipe-to-`grep' ....

agreed.
Note grep 2.4 got the -Z option to OUTPUT a \0 after each filename
(which doesn't help in this case, but useful nonetheless).
Note also I'm in the process of completing a patch to textutils to add
standard args (including --null) to each.

[snip]

Padraig.





More information about the ILUG mailing list