小编dar*_*ale的帖子

如何在 Bash 中运行由多个变量分隔的命令?

我想运行一个由几个“片段”组成的命令。

php="php"
options="-l"

for f in `git diff-index --cached --name-only HEAD | grep -e '\(php\|phtml\)$'`; do
   if [ -f $f ]; then
       # Here I want to run my command defined
       # in $php and $options and put the result in
       # $php_lint var
       # like this command would do:
       # php_lint=$(php -l $f)
       # but with something like that:
       # php_lint=eval $php $options $f
   fi
done
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

更新:

在某个特定点上挣扎之后,我问了这个问题:

请看一下,它也可以帮助您。

command-line bash

4
推荐指数
1
解决办法
304
查看次数

标签 统计

bash ×1

command-line ×1