unix find command on cmder.exe in windows

11,389

Solution 1

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

Solution 2

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

Share:
11,389

Related videos on Youtube

Heisenbug
Author by

Heisenbug

Updated on September 18, 2022

Comments

  • Heisenbug
    Heisenbug over 1 year

    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?

    • Admin
      Admin almost 7 years
      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%
    • Admin
      Admin almost 7 years
      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.
    • Admin
      Admin almost 7 years
    • Admin
      Admin almost 7 years
    • Admin
      Admin almost 7 years
      @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.
    • Admin
      Admin almost 7 years
      @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.
    • Admin
      Admin over 6 years
      You may wish to move %git_install_root% where the new PATH is constructed in init.bat, see github.com/cmderdev/cmder/issues/37
  • Heisenbug
    Heisenbug almost 7 years
    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!
  • simlev
    simlev almost 7 years
    @Heisenbug cmder has the obvious advantage of being portable and not needing installation to be performed by a privileged user.
  • phuclv
    phuclv almost 7 years
    you can also simply rename the *nix find to another name like fnd.exe
  • Heisenbug
    Heisenbug almost 7 years
    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.
  • Admin
    Admin about 6 years
    Isn't gnu find normally called gfind on non-gnu systems?
  • Cale Sweeney
    Cale Sweeney over 2 years
    Jerem is referring to the windows find here: C:\Windows\System32\find.exe. In the System variables path it looks like %SystemRoot%\system32, usually towards the top.
  • Cale Sweeney
    Cale Sweeney over 2 years
    Don't let it confuse you that after you successfully setup your find alias, λ which find still responds with /c/windows/system32/find. λ which find cares about your path, not your cmder alias.