linux - 如何在 Windows 上确定 Git-Bash 二进制文件的优先级

标签 linux cmd path find git-bash

我在 Windows 构建代理上安装了 Git Bash,在运行脚本时,每当我使用“查找”时,它都会运行 DOS 查找 (https://technet.microsoft.com/en-us/library/bb490906.aspx) 而不是 Unix 查找。让我的脚本在 C:\Program Files\Git\usr\bin 中获取 find.exe 的最佳方法是什么?

λ find /?
Searches for a text string in a file or files.

FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]

我必须明确说明路径,或者在执行命令时在 bin 目录中才能获取 Unix 风格的查找

λ "c:\Program Files\Git\usr\bin\find.exe" --help
Usage: /usr/bin/find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

谢谢!

最佳答案

我通常使用简化的 PATH:

set G=c:\path\to\latest\git
set PATH=%G%\bin;%G%\usr\bin;%G%\mingw64\bin
set PATH=%PATH%;C:\windows\system32;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\

如果GH(Git 安装文件夹)设置之前Windows\System32,将选择从Git 中查找而不是默认的Windows一个。

您可以键入where find,以检查找到该命令的位置。

关于linux - 如何在 Windows 上确定 Git-Bash 二进制文件的优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47382660/

相关文章:

c# - 如何禁用写入 T4 生成输出文件的 #line 指令

linux - 在类似 Linux/UNIX 的纯文本文件中隐藏网络代理密码

linux - 检查文件是否存在 cron 作业

regex - Asterisk 应用拨号方案中的模式匹配

windows - Windows/cmd.exe 与 Linux/bash 的 $ 等价物是什么? -- 程序退出/返回代码?

node.js - Nginx proxy_pass 和绝对路径

ruby - 如何为 Ruby 设置 Notepad++ 运行命令?

linux - BASH 将文本文件逐行转换为变量

powershell - 在 Windows Docker 容器 Windows Server 2016 中运行时出现 Windows Defender/更新问题

batch-file - 批量获取最接近完美平方的数字