[RndTbl] *reading* a file causes reboot
Gilbert E. Detillieux
gedetil at cs.umanitoba.ca
Tue May 5 10:50:51 CDT 2015
On 04/05/2015 10:59 PM, Adam Thompson wrote:
> I've found "find / -xdev -type f -print0 | xargs grep string /dev/null"
> to be completely reliable and reasonably portable. Not to mention a lot
> faster. Faster yet if you use any of the #NN arguments to xargs to batch
> the grep invocations.
I'd also use the xargs -r (or --no-run-if-empty) option, to avoid
running the command if there are no args. (It may not particularly
matter in this case, but it can sometimes be quite significant.)
> I started doing that because every time I ran grep -r, it would just
> hang somewhere in /etc.
Yeah, that's been my experience as well...
> On May 4, 2015 10:51:08 PM CDT, Trevor Cordes <trevor at tecnopolis.ca> wrote:
...
> Or... I just RTFM and it looks like gnu grep solved the symlink problem
> already:
>
> -r, --recursive
> Read all files under each directory, recursively,
> following symbolic links only if they are on the command line. Note
> that if no file operand is given, grep
> searches the working directory. This is equivalent to
> the -d recurse option.
>
> -R, --dereference-recursive
> Read all files under each directory, recursively. Follow
> all sy!
> mbolic
> links, unlike -r.
>
> So that explains why I've never hit a symlink loop: I've never used -R
> (capital).
This if a more recent addition to GNU grep. E.g. on RHEL 6 systems, -R
and -r are the same, and the man page makes no mention of special
handling of symlinks. (Hence the possibility of loops and hanging.)
--
Gilbert E. Detillieux E-mail: <gedetil at muug.mb.ca>
Manitoba UNIX User Group Web: http://www.muug.mb.ca/
PO Box 130 St-Boniface Phone: (204)474-8161
Winnipeg MB CANADA R2H 3B4 Fax: (204)474-7609
More information about the Roundtable
mailing list