我的命令输出如下所示:
XYZ Server Version 15.2.8 (10095.48)
如何使用 awk 只打印 10095? (可能有 4 或 6 个数字,而不是 5 个)
此外,如果我有如下输出:
XYZ Server Version: 12.2.4.8638
如何打印点后面的输出?它应该看起来像这样:8638
最佳答案
您可以使用-F
来定义“字段分隔符”:
How can I use awk in order to print only 10095? (there might be 4 or 6 numbers instead of 5)
echo "XYZ Server Version 15.2.8 (10095.48)" | awk -F'(' '{print $2}' | awk -F')' '{print $1}' | awk -F'.' '{print $1}'
How can I print the output that follows the dot? It should look like this: 8638
echo "XYZ Server Version: 12.2.4.8638" | awk -F'.' '{print $NF}'
关于linux - 如何使用 awk 去掉输出最后一列的字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57571081/