Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要将此命令的输出保存到变量中
$scriptName | awk '{split($0,a,"_"); print a[1]}'
我试图这样做,但没有奏效
schema=$( $scriptName | awk '{split($0,a,"_"); print a[1]}' )
请有人告诉我这样做吗?谢谢你。
这是一个稍微简单的方法:
schema=`echo $scriptName |awk -F_ '{print $1}'`
第三种选择:
$script | awk ' ... ' | read schema
尝试
schema="$( $scriptName | awk '{split($0,a,"_"); print a[1]}' )"
(带引号)。但是你如何检查它是否有效?