分割字符串使用数组AWK [英] split string to array using awk
本文介绍了分割字符串使用数组AWK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何时,它包含了管道符号分割字符串|
在里面。
我想分裂他们在数组中。
How to split the string when it contains pipe symbols |
in it.
I want to split them to be in array.
我试过
echo "12:23:11" | awk '{split($0,a,":"); print a[3] a[2] a[1]}'
工作正常。如果我的字符串是像12 | 23 | 11?
那么我怎么将它们分为数组
Which works fine. If my string is like "12|23|11"
then how do I split them into array?
推荐答案
你试过:
echo "12|23|11" | awk '{split($0,a,"|"); print a[3],a[2],a[1]}'
这篇关于分割字符串使用数组AWK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文