开发者

Create grep command dynamic and run from variable

开发者 https://www.devze.com 2022-12-14 06:45 出处:网络
I am trying to create regex dynamic开发者_高级运维ly and then run it, this is part of script ...

I am trying to create regex dynamic开发者_高级运维ly and then run it, this is part of script

...
param="egrep $2 $1"
shift
shift
while [ $# -ne 0 ]
do
param="$param""|egrep $1"
shift
done
$param // here i get error
...

But echo for $param seems to me ok

.P F1 a b c // run script

egrep a F1| egrep b| egrep c

What should I do in order to run $param correctly?


try

eval $param


try: eval $cmd


0

精彩评论

暂无评论...
验证码 换一张
取 消