试图awk命令的输出分配给数组 [英] Trying to assign output of awk command to an array

查看:147
本文介绍了试图awk命令的输出分配给数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有AWK返回的输出如下:

I have the following output returned by awk:

qh1adm 20130711151154 : tp import all QH1 u6 -Dsourcesystems=BFI,EBJ
qh1adm 20130711151155 : tp import all QH1 u6 -Dsourcesystems=E7B,B17  
qh1adm 20130711151200 : tp import all QH1 u6 -Dsourcesystems=BFI,EBJ

欲存储此在顺序计数的记录数的阵列。如果超过1才把我想显示这个数组的内容。能否请您协助?

I want to store this in an array in-order to count the number of records. If it is more than 1 only then I want to display the contents of this array. Can you please assist?

非常感谢。

推荐答案

使用bash / zsh中,捕获输出,算上线,并将其打印是否符合您的标准:

Using bash/zsh, capture the output, count the lines, and print it if it meets your criteria:

output=$(awk 'something that returns what you showed in your question')
nlines=$(wc -l <<< "$output")
if ((nlines > 1)); then
    echo "$output"
fi

这篇关于试图awk命令的输出分配给数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆