Cygwin "find" returns nothing

0

This command returns nothing in Cygwin running on Windows Server 2008 r2:

/usr/bin/find /

I get a slight pause, but no text is returned. No error, no results, etc. I've tried with different search paths, using arguments (like -type f), and set my cygwin path to just /usr/local/bin:/usr/bin. Nothing works.

Ideas?

Thanks

SArcher

Posted 2014-03-06T19:19:17.970

Reputation: 101

Well...If I tell you to "go find" something, what do you do? – not2qubit – 2014-03-08T11:49:21.800

If you think my syntax is wrong, tou clearly don't understand how the find command works. – SArcher – 2014-03-11T18:07:10.320

The correct answer is: WHAT do you want me to find? – not2qubit – 2014-03-12T13:13:04.147

Okay user1147688, here's how find is supposed to work: When "find /" is called, it should dump a list of all objects in the file system. – SArcher – 2014-03-13T00:26:43.393

Probably your $PATH is messed up or missing. What does echo $PATH give you? (And where did you set it?) Make sure it's set as a system variable and not a local user variable (in windows), but you can also override in .bashrc. – not2qubit – 2014-03-16T15:45:20.983

As I said in the question, path is set to /usr/local/bin:/usr/bin. – SArcher – 2014-03-17T15:55:44.400

Answers

0

That’s very strange behaviour and I’ve never come across anything like that while using Cygwin. I don’t have enough reputation points to ask for information using comments so I’ll just post the debugging techiques that I would use. Hopefully, they’ll be of use to anyone else who has similar issues.

Firstly, I’d try to verify that I was running the correct executable. Running find --version should return something like the following:

find (GNU findutils) 4.5.11

Packaged by Cygwin (4.5.11-1)

If I still wasn’t getting any output, I’d (install and) use Cygwin’s strace command:

mkdir testdir
strace -o find.out find testdir
rmdir testdir

strace allows you to see what calls a Cygwin executable makes to the Cygwin DLL. With the above command, the output of the find command is stored in find.out.

Unless you’re familiar with Windows system programming, much of it won’t make sense. However, looking through the output will still give you an idea of what the command is doing, e.g., the Cygwin PATH and other environment variables being passed to the command are captured. I usually search for open( to see what files the command (find) is attempting to use. Successful calls to the open function will be displayed like:

open: open(/home/anthony/t, 0x30C000)
open: open(., 0x400000)

Unsuccesful calls to open return a value of -1. Note that not all files that find attempts to open are actually required for the command to operate correctly. This is an example of one such unsuccesful attempt (the information in locale.alias would be read if it existed but it’s not necessary for find to do its job):

open: -1 = open(/usr/local/share/locale/locale.alias, 0x8000), errno 2

Note: I create (and then remove) the empty testdir directory so there isn’t an overwhelming amount of information captured to the strace output file.

Anthony Geoghegan

Posted 2014-03-06T19:19:17.970

Reputation: 3 095

Thank you, strace is a good idea. I ended up wiping out the OS so I can't try your idea. – SArcher – 2014-07-18T20:56:26.180