echo -e 'one two three\nfour five six\nseven eight nine'
one two three
four five six
seven eight nine
我该如何做一些“魔术”来获得此输出?:
three
six
nine
更新:我不需要这种特定的方式,我需要一个通用的解决方案,以便无论一行中有多少列,例如:awk始终显示最后一列。
它甚至可以只完成'bash'
,无'sed'
,'awk'
或'perl'
:
echo -e 'one two three\nfour five six\nseven eight nine' |
while IFS=" " read -r -a line; do
nb=${#line[@]}
echo ${line[$((nb - 1))]}
done
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句