Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Markus Wichmann
On Thu, Dec 12, 2013 at 02:32:03PM -0500, Andrew Gwozdziewycz wrote: > find(1) seems very un-unixy, but it's very powerful. It's not, though, because ultimately it's just a file system walk with a system for querying stat(2). No, the problem I have with find is that its output is not necessarily s

Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Andrew Gwozdziewycz
On Thu, Dec 12, 2013 at 5:30 PM, Andrew Gwozdziewycz wrote: > On Thu, Dec 12, 2013 at 5:26 PM, Bobby Powers wrote: >> Hello, >> >> Andrew Gwozdziewycz wrote: $ time find / | grep 'bin' > /dev/null real0m8.122s user0m3.101s sys 0m2.519s $ time find / -rege

Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Andrew Gwozdziewycz
On Thu, Dec 12, 2013 at 5:26 PM, Bobby Powers wrote: > Hello, > > Andrew Gwozdziewycz wrote: >>> $ time find / | grep 'bin' > /dev/null >>> real0m8.122s >>> user0m3.101s >>> sys 0m2.519s >>> >>> $ time find / -regex 'bin' | grep >>> real0m18.795s >>> user0m3.394s >>> sys 0m

Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Bobby Powers
Hello, Andrew Gwozdziewycz wrote: >> $ time find / | grep 'bin' > /dev/null >> real0m8.122s >> user0m3.101s >> sys 0m2.519s >> >> $ time find / -regex 'bin' | grep >> real0m18.795s >> user0m3.394s >> sys 0m3.401s I get a different story on Linux 3.12.4: [bpowers@fina ~]$

Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Andrew Gwozdziewycz
Huge copy paste fail! > Also, just for kicks I ran a comparison: > > $ time find / | grep 'bin' > /dev/null > real0m8.122s > user0m3.101s > sys 0m2.519s > > $ time find / -regex 'bin' | grep > real0m18.795s > user0m3.394s > sys 0m3.401s That should have been $ time find

Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Andrew Gwozdziewycz
On Thu, Dec 12, 2013 at 3:36 PM, Troels Henriksen wrote: > Troels Henriksen writes: > >> Andrew Gwozdziewycz writes: >> >>> Assume that each filter halves the fileset of, say, 256 files (my /etc >>> directory on this OSX machine has just 247 files). That's less than >>> 512 calls with a few filt

Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Raphaël Proust
On Thu, Dec 12, 2013 at 7:32 PM, Andrew Gwozdziewycz wrote: > Thoughts? Pointers to tools that already do this? When I need to do something like that, I use rc(1) and the plan9 version of ls(1). It shell-quotes the filenames by default which is very useful! -- __ Raphaël Proust

Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Charlie Kester
On Thu 12 Dec 2013 at 11:32:03 PST Andrew Gwozdziewycz wrote: walk - (implements find $1) AT&T Research has a tool called tw ("treewalk") that does this: http://www2.research.att.com/sw/download/man/man1/tw.html Assuming the sourcecode I downloaded a while ago is still current, it's licensed

Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Raphaël Proust
On Thu, Dec 12, 2013 at 7:36 PM, Chris Down wrote: > On 2013-12-12 14:32:03 -0500, Andrew Gwozdziewycz wrote: >> So, to find all files in /etc modified within the last hour... >> >> walk /etc | agep -1H - >> >> Or, >> >> walk /etc | xargs agep -1H > > The problem here is speed. For any non-trivial

Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Troels Henriksen
Troels Henriksen writes: > Andrew Gwozdziewycz writes: > >> Assume that each filter halves the fileset of, say, 256 files (my /etc >> directory on this OSX machine has just 247 files). That's less than >> 512 calls with a few filters. Is that really so bad on modern >> hardware? > > If you have

Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Troels Henriksen
Andrew Gwozdziewycz writes: > Assume that each filter halves the fileset of, say, 256 files (my /etc > directory on this OSX machine has just 247 files). That's less than > 512 calls with a few filters. Is that really so bad on modern > hardware? If you have only 256 files, you can do almost any

Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Andrew Gwozdziewycz
On Thu, Dec 12, 2013 at 2:36 PM, Chris Down wrote: > On 2013-12-12 14:32:03 -0500, Andrew Gwozdziewycz wrote: >> So, to find all files in /etc modified within the last hour... >> >> walk /etc | agep -1H - >> >> Or, >> >> walk /etc | xargs agep -1H > > The problem here is speed. For any non-trivial

Re: [dev] alternatives to find for querying the filesystem

2013-12-12 Thread Chris Down
On 2013-12-12 14:32:03 -0500, Andrew Gwozdziewycz wrote: > So, to find all files in /etc modified within the last hour... > > walk /etc | agep -1H - > > Or, > > walk /etc | xargs agep -1H The problem here is speed. For any non-trivial number of files, this will become non-negligibly slower due

[dev] alternatives to find for querying the filesystem

2013-12-12 Thread Andrew Gwozdziewycz
find(1) seems very un-unixy, but it's very powerful. Let's assume for a minute that find didn't exist. How would you do the following: 1. execute a command for each file (find . -exec whatever {} \;) 2. find files that are > 8M 3. find files that are older than 20 days 4. find all files that a