Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 如何从shell命令输出中复制搜索到的模式之前的第一个模式_Linux_Shell_Unix_Awk_Grep - Fatal编程技术网

Linux 如何从shell命令输出中复制搜索到的模式之前的第一个模式

Linux 如何从shell命令输出中复制搜索到的模式之前的第一个模式,linux,shell,unix,awk,grep,Linux,Shell,Unix,Awk,Grep,我从shell命令得到如下输出: theme get --list -p=$PASS -s=$STORE v=`theme get --list -p=$PASS -s=$STORE | grep '[live]' 输出: Available theme versions: [10462576304] Debut [134241503419] 1.0.4 [32602837511] 1.0.5 [223235633345] [live] test 我想在匹配[live]f.e 22

我从shell命令得到如下输出:

theme get --list -p=$PASS -s=$STORE
v=`theme get --list -p=$PASS -s=$STORE | grep '[live]'
输出:

Available theme versions:

[10462576304] Debut

[134241503419] 1.0.4

[32602837511] 1.0.5

[223235633345] [live] test
我想在匹配[live]f.e 223235633345之前导出到[]之间的变量号

模式[live]并不总是可以在最后一行,但我只想在[live]之前的第一行输入唯一的ID号

我是这样开始的:

theme get --list -p=$PASS -s=$STORE
v=`theme get --list -p=$PASS -s=$STORE | grep '[live]'
此awk适用于您:

主题get-list-p=$PASS-s=$STORE| awk'{for i=1;i此awk应适用于您:

主题get-list-p=$PASS-s=$STORE|
awk'{for i=1;我请显示您的尝试代码我已更新问题请显示您的尝试代码我已更新问题非常感谢anubhava!它确实帮助我解决了我的问题。我需要对工作进行一些更正,但它很棒!!主题get-list-p=$PASS-s=$STORE | awk'{对于i=1;我非常感谢你anubhava!它真的帮助我解决了我的问题。我必须对工作进行一些修改,但这很好!!theme get-list-p=$PASS-s=$STORE | awk'{对于i=1;i