【问题标题】:Create a bat file for git-bash script为 git-bash 脚本创建一个 bat 文件
【发布时间】:2017-12-07 22:23:10
【问题描述】:

大家好。我安装了一个 git-bash 并想要一些自动化。我有一个 .bat 文件,我想运行它

some.bat param | iconv -cp1251 > l.log | tail -f l.log

我不想在 WinCMD 中而是在 git-bash shell 中运行它 - 请告诉我该怎么做?

【问题讨论】:

    标签: batch-file git-bash


    【解决方案1】:

    Windows 上的 Git bash 使用 BASH。您可以使用 bash 创建一个快速脚本,该脚本可以接收参数并回显它们,以便您可以将它们通过管道传递给您的下一个实用程序。

    它可能看起来像这样

    文件:some.sh

     #!/bin/bash
    
     #Lots of fun bash scripting here...
    
     echo $1 
     # $1 here is the first parameter sent to this script. 
     # $2 is the second... etc. $0 is the script name 
    

    然后将 some.sh 设置为可执行文件

    $ chmod +x some.sh
    

    然后你就可以在 git-bash shell 中执行它了

    ./some.sh param | cat ... etc | etc...
    

    您可以阅读有关 bash 编程的信息

    我建议查看一些 bash 脚本教程,例如 this one

    【讨论】:

      猜你喜欢
      • 2011-06-02
      • 1970-01-01
      • 1970-01-01
      • 2013-09-26
      • 1970-01-01
      • 2011-11-25
      • 1970-01-01
      • 1970-01-01
      • 2017-01-26
      相关资源
      最近更新 更多