10

I installed cmder shell emulator for Windows.

Works fine but I can't use Unix's find command. Apparently when I type:

'find .'

in the terminal it tries to use the Windows' FIND and output this error:

FIND: Parameter format not correct

I'd really like to use find, any hint on how to get it working?

  • 1
    You would need to make whichever directory find is in appear before C:\Windows\System32 (where Windows' find lives) in the PATH environment variable. This is generally considered not a great idea to do globally as it tends to confuse other programs that expect a standard Windows environment. Rather, you should see if you can set a startup script in Cmder, and make the script do something like set PATH=C:\path\to\folder\with\unix\find;%PATH% – Bob Jun 14 '17 at 10:15
  • I don't know cmder, but in Linux/Unix which -a find will show all programs which could execute with the find command. Identify the Unix find. Then use its full path, or re-arrange the order of PATH directories, or set an alias, if cmder supports this; you could also rename the Windows find.exe to wfind.exe. If it emulates bash, then you can use the in-built type -a find. – AFH Jun 14 '17 at 10:20
  • 1
    Possible duplicate of How do I rename C:\Windows\System32\convert.exe? – phuclv Jun 15 '17 at 2:31
  • @AFH which -a find returns /c/WINDOWS/system32/find /usr/bin/find. Unfortunately, though, running /usr/bin/find yields The system cannot find the path specified.. It seems the actual windows-style path is needed here. Running type launches the windows type, and it appears cmder does not provide the unix-like version. – simlev Jun 15 '17 at 8:15
13

Simplest solution is to create an alias to the find executable within the cmder installation folder:

λ which find
/c/WINDOWS/system32/find
λ find --help
FIND: FIND: Parameter format not correct
λ alias find=C:\Files\Programs\cmder\vendor\git-for-windows\usr\bin\find.exe $*
λ find --help
Usage: /usr/bin/find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

May I suggest you also try out Cygwin where, among other things, find works out of the box. That is what I used to ascertain the location of the cmder-supplied find.exe.

Kudos to @Bob and @AFH for their insightful comments, and to @Lưu Vĩnh Phúc for suggesting another dead-simple solution:

rename the *nix find to another name like fnd.exe

This might actually be preferrable over creating an alias, because cmder aliases don't work in Windows 10 unless Use legacy console is selected in cmd properties (see how to do it).

| improve this answer | |
  • Thanks for the suggestion. Seems the best way to go. I normally use cygwin when on windows but for working reasons I am forced to cmder right now. I will try this asap! – Heisenbug Jun 14 '17 at 15:28
  • @Heisenbug cmder has the obvious advantage of being portable and not needing installation to be performed by a privileged user. – simlev Jun 14 '17 at 15:39
  • you can also simply rename the *nix find to another name like fnd.exe – phuclv Jun 14 '17 at 16:31
  • I renamed the unix version, to avoid modifying windows native stuff. But thanks, what I was really missing was the folder where those commands where stored and your answer helped me. – Heisenbug Jun 15 '17 at 8:05
  • Isn't gnu find normally called gfind on non-gnu systems? – user27163 Feb 26 '18 at 22:43
4

Cmder\vendor\git-for-windows\usr\bin is added to the PATH by Cmder\vendor\init.bat. Unfortunately, it's added at the end of the PATH, so Windows's find.exe is found first.

Fortunately, it's easy to fix. Just add this line inside Cmder\config\user-profile.cmd:

set "PATH=%GIT_INSTALL_ROOT%\usr\bin;%PATH%"

| improve this answer | |
0

I have installed smartgit in windows

Then I add C:\Program Files (x86)\SmartGit\git\bin (my smartgit folder) into path environment

press win+r enter bash. in the bash shell you can use find command. in Cmder you also can type bash to use it

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.