【发布时间】: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
大家好。我安装了一个 git-bash 并想要一些自动化。我有一个 .bat 文件,我想运行它
some.bat param | iconv -cp1251 > l.log | tail -f l.log
我不想在 WinCMD 中而是在 git-bash shell 中运行它 - 请告诉我该怎么做?
【问题讨论】:
标签: batch-file git-bash
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
【讨论】: