unix find command on cmder.exe in windows

10

2

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?

Heisenbug

Posted 2017-06-14T10:10:58.710

Reputation: 645

1You 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 – 2017-06-14T10:15:21.500

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 – 2017-06-14T10:20:45.740

1

Possible duplicate of How do I rename C:\Windows\System32\convert.exe?

– phuclv – 2017-06-15T02:31:46.577

@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 – 2017-06-15T08:15:09.853

@simlev - As you say, Cygwin or (if on Win10) WSL may be a better bet, though it is less easy to call native Windows programs, which may not suit the questioner. – AFH – 2017-06-15T09:23:03.703

You may wish to move %git_install_root% where the new PATH is constructed in init.bat, see https://github.com/cmderdev/cmder/issues/37

– Bob – 2017-09-01T05:47:29.733

Answers

11

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).

simlev

Posted 2017-06-14T10:10:58.710

Reputation: 3 184

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 – 2017-06-14T15:28:57.770

@Heisenbug cmder has the obvious advantage of being portable and not needing installation to be performed by a privileged user. – simlev – 2017-06-14T15:39:15.563

you can also simply rename the *nix find to another name like fnd.exe – phuclv – 2017-06-14T16:31:35.573

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 – 2017-06-15T08:05:26.027

Isn't gnu find normally called gfind on non-gnu systems? – None – 2018-02-26T22:43:08.717

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%"

Jerem

Posted 2017-06-14T10:10:58.710

Reputation: 171

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

lovebanyi

Posted 2017-06-14T10:10:58.710

Reputation: 1