从BASH,从AWK指数阵 [英] Array from BASH, index from AWK
本文介绍了从BASH,从AWK指数阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能使用在AWK定义指数BASH数组值?
击:
表=(A B C D E)
说明| awk的BEGIN {指数= 0} {打印\\$ {表[** **索引]} \\;指数+}
解决方案
您可以做到这一点,但为什么呢?
表=(A B C D E); AWK -vt =$ {表[*]}'BEGIN {N =拆分(T,A,);对于(i = 1; I< = N;我++)打印[I]}一个
b
C
ð
Ë
你可以在bash数组元素访问直接为好。
Is there any possibility to get value from BASH array using index defined in AWK?
Bash:
table=(a b c d e)
instructions | awk " BEGIN {index=0} {print \"${table[**index**]}\"; index++} "
解决方案
You can do this but why?
table=(a b c d e); awk -vt="${table[*]}" 'BEGIN{n=split(t,a," "); for(i=1;i<=n;i++) print a[i]}'
a
b
c
d
e
you can do the array element access in bash directly as well.
这篇关于从BASH,从AWK指数阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文