News for hackers. Stuff that matters.
Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by amoss on Wednesday June 21, 2023 @03:22AM (#36415441)
The thing that I use find for most commonly is to perform a hierarchical grep, i.e

find . -exec grep -Hn regex \{\} \;

How would you do that with the du | grep combo?

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by geosh on Wednesday June 21, 2023 @04:11AM (#36415792)
... | xargs grep -Hn regex

This will also be faster, because you fork less.

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by arp242 on Wednesday June 21, 2023 @04:45AM (#36416027)
Using \+ instead of \; will do the same (fork less).

du -a will need to do a stat to get the file size, which is comparatively expensive; I don't think find will (not sure)?

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by jlokier on Wednesday June 21, 2023 @07:07AM (#36416969)
You're right, find won't call stat() unless it needs to. It doesn't need to for recursing through the directory tree because readdir() returns dirent.d_type these days to determine if a name is a directory.

Yes, those stat() calls can be very slow in aggregate on a large tree, especially from HDD (due to seeking) or network filesystem, if the stat information isn't already in cache.

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by geosh on Wednesday June 21, 2023 @01:13PM (#36421397)
Oh, I forgot about \+. I still pipe to xargs every single time.
Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by ykonstant on Wednesday June 21, 2023 @05:07AM (#36416183)
Does this deal with arbitrary filenames (having newlines, control chars etc) correctly? Or does Plan9 forbid such filenames?
Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by geosh on Wednesday June 21, 2023 @01:13PM (#36421385)
I've never used plan9. In Linux you do "find -print0 | xargs -0" to deal with that.

Im not sure how one can do \0 separator with du, plan9's du(1) doesn't list such option.

Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by somat on Wednesday June 21, 2023 @04:26AM (#36415906)
grep -R
Re:Linux Namespaces Are a Poor Man's Plan 9 Namespaces by amoss on Wednesday June 21, 2023 @06:09AM (#36416622)
but old habits die hard :)