gpt4 book ai didi

linux - 执行在脚本中硬编码的命令在变量中时不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 09:56:53 26 4
gpt4 key购买 nike

这个有效:

nc shldvgfas005 6155 < temp.6153 

这挂起:

cmd="nc shldvgfas005 6153 < temp.6153"; $cmd

这给出了一个错误:

cmd="nc shldvgfas005 6153 < temp.6153"; "$cmd"

-bash: nc shldvgfas005 6153 < temp.6153: command not found

帮助!

最佳答案

BASH 常见问题 entry #50 :

I'm trying to put a command in a variable, but the complex cases always fail!

Variables hold data. Functions hold code. Don't put code inside variables! There are many situations in which people try to shove commands, or command arguments, into variables and then run them. Each case needs to be handled separately.

关于linux - 执行在脚本中硬编码的命令在变量中时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2918298/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com