我有一个存储在文件中的线程列表.我可以用grep检索线程名称:
$grep "#" stack.out "MSC service thread 1-8" #20 prio=5 os_prio=0 tid=0x00007f473c045800 nid=0x7f8 waiting on condition [0x00007f4795216000] "MSC service thread 1-7" #19 prio=5 os_prio=0 tid=0x00007f4740001000 nid=0x7f7 waiting on condition [0x00007f479531b000] "MSC service thread 1-6" #18 prio=5 os_prio=0 tid=0x00007f4738001000 nid=0x7f4 waiting on condition [0x00007f479541c000] . . .
由于我需要操作此列表的输出,我需要将这些行存储在Array中.
我发现了一些建议这种方法的例子:
$export my_array=( $(grep "#" stack.out) )
但是,如果我浏览数组,我的早期grep没有得到相同的结果:
$printf '%s\n' "${my_array[@]}" "MSC service thread 1-8" #20 prio=5 os_prio=0 tid=0x00007f473c045800 nid=0x7f8 waiting on condition [0x00007f4795216000] "MSC service thread 1-7" #19 prio=5 os_prio=0 tid=0x00007f4740001000 nid=0x7f7 waiting on condition [0x00007f479531b000]
似乎回车正在弄乱我的阵列分配.
任何帮助如何解决它?
谢谢 !