我有一个makefile,其中包含一个Rules.mak文件,该文件包含我想要使用的工具.问题是,如果工具文件夹要提取版本或使用"本机"安装,则它们具有空闲选项.所以我希望包含工具提取规则(如果存在),否则我想要包含本机文件.
这样的事情是目标:
if Tool/Rules.mak exists then
include Tool/Rules.mak
else
include common/Rules-Tool.mak
fi
Run Code Online (Sandbox Code Playgroud)
我已尝试过bash方式或make方式但是因为这是设置环境的前提条件我没有特定目标但由于检查失败而使调用错误.
if [ -f Tool/Rules.mak ]
then
echo testfile exists!
fi
Run Code Online (Sandbox Code Playgroud)
也
if [ -d ./Tool ]
then
echo testfile exists!
fi
Run Code Online (Sandbox Code Playgroud)
以及带引号和类似的版本.问题是,当我输入时几乎所有时间都会出现以下错误:
Rules.mak:14: *** missing separator. Stop.
Run Code Online (Sandbox Code Playgroud) 我只是尝试了一个我需要修改的同事设置的剧本.我在mac上运行的第一个问题是
ERROR: Unable to find an inventory file, specify one with -i ?
Run Code Online (Sandbox Code Playgroud)
通过在命令中添加-i verif可以轻松解决这个问题.但随后出现以下错误.
loadgen-verif-app1.internal.machines | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/andreas.joelsson/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: auto-mux: Trying existing master
ControlPath too long
Run Code Online (Sandbox Code Playgroud)
所有8台机器都是如此(loadgen-verif-app [1-8] .internal.machines)
经过一些调试,文件可能太长了,我尝试了以下命令,结果相同:
ansible nukes -m ping -i verif -vvvv
Run Code Online (Sandbox Code Playgroud)
然后我认为这是ssh的问题,但通过ssh执行命令工作:
ssh loadgen-verif-app1.internal.machines ping loadgen-verif-app2.internal.machines
Run Code Online (Sandbox Code Playgroud)
现在我很难过,因为ping命令适用于上面列出的范围内的某些机器,问题是它们比 …
我有一个脚本,我想在文件夹中找到纯数字的所有直接子目录,并将它们复制到指定的目标.我有问题获得正则表达式一起工作+,并*在find.示例中的文件夹结构如下:
0/
1/
2/
3/
3.02asd/
3a/
4/
44/
45/
451/
452/
453/
4531/
4532/
45321/
45322/
45323/
666aa/
66a/
66aaa/
temp27/
Run Code Online (Sandbox Code Playgroud)
我已经使用以下命令:
find . -type d -maxdepth 1 -name "[0-9]" | while read f
do
mv $f $TESTPATH
done
find . -type d -maxdepth 1 -name "[0-9][0-9]" | while read f
do
mv $f $TESTPATH
done
find . -type d -maxdepth 1 -name "[0-9][0-9][0-9]" | while read f
do
mv $f $TESTPATH
done …Run Code Online (Sandbox Code Playgroud) 我有一个关于我正在编写的shell脚本的bash函数的问题.功能如下:
do_command() {
if [[ $DRY_RUN ]]; then
echo $@
else
$@
fi
}
Run Code Online (Sandbox Code Playgroud)
功能很简单,如果设置了DRY_RUN标志,我们只需打印方法,否则执行.这适用于大多数命令,除了git tag命令,我尝试过不同版本的:
do_command git tag -a $NEW_VERSION -m '$INPUT_COMMENT'
Run Code Online (Sandbox Code Playgroud)
这实际上执行了tag命令,但是给出了注释$ INPUT_COMMENT
我已经尝试了2个其他版本,它们提供了正确的echo输出,但是不允许我执行git tag命令.
do_command git tag -a $NEW_VERSION -m "$INPUT_COMMENT"
Run Code Online (Sandbox Code Playgroud)
和
do_command git tag -a $NEW_VERSION -m "\"$INPUT_COMMENT\""
Run Code Online (Sandbox Code Playgroud)
有没有办法让echo和git命令在这个调用中工作?或者我需要解析do_command版本?