标签: awk
我有带分隔字段的字符串,但每个字段中包含不同数量的字段,例如:
我想在每种情况下检索最后两个字段,即:
使用substring_index函数在MySQL中很容易,我看到this thread解释了如何在PHP中完成它。
有人可以帮助我在命令行中使用awk实现相同的功能吗?感谢
答案 0 :(得分:4)
echo 'this/that/theother/stuff' | awk -F/ '{print $(NF-1) "/" $(NF)}'