使用bash shell

时间:2015-10-08 08:57:49

标签: bash shell sed

我有以下字符串

1234 1 xyz123 4321 1 456778 32124 1 abbba 56789 1 hfhfn456

我想提取以下子串。需要多次提取。

abbba 
456778 
hfhfn456
xyz123 

使用bash shell,awk或sed或grep是否可能?

1 个答案:

答案 0 :(得分:0)

如果安装了GNU coreutils并且列出结果的顺序无关紧要,您也可以使用cuttr

echo "1234 1 xyz123 4321 1 456778 32124 1 abbba 56789 1 hfhfn456" | \
    cut -d' ' -f'3,6,9,12' | tr " " "\n"

输出:

abbba 
456778 
hfhfn456
xyz123 
相关问题