我们有如下文件
more file
-rwxrwxrwt 3 hdfs hdfs 30 2021-06-09 07:10 /noij/gtdf/license_alerts/alert_1_1623222654527
-rwxrwxrwt 3 hdfs hdfs 30 2021-06-09 07:10 /noij/gtdf/license_alerts/alert_1_1623222654679
-rwxrwxrwt 3 hdfs hdfs 30 2021-06-09 07:10 /noij/gtdf/license_alerts/alert_1_1623222654744
-rwxrwxrwt 3 hdfs hdfs 30 2021-06-09 08:02 /noij/gtdf/license_alerts/alert_1_1623225746040_69
-rwxrwxrwt 3 hdfs hdfs 30 2021-06-09 08:02 /noij/gtdf/license_alerts/alert_1_1623225746059_66
-rwxrwxrwt 3 hdfs hdfs 30 2021-06-09 08:02 /noij/gtdf/license_alerts/alert_1_1623225746061_65
-rwxrwxrwt 3 hdfs hdfs 30 2021-06-09 08:02 /noij/gtdf/license_alerts/alert_1_1623225746162_65
Run Code Online (Sandbox Code Playgroud)
虽然我需要取最后一个数字但排除数字是否包含 1-3 位数字
预期结果应该是
1623222654527
1623222654679
1623222654744
Run Code Online (Sandbox Code Playgroud)
所以我到目前为止的方法是
sed s'/_/ /g' file | awk '{print $NF}'
Run Code Online (Sandbox Code Playgroud)
但它的印刷品
1623222654527
1623222654679
1623222654744
69
66
65
65
Run Code Online (Sandbox Code Playgroud)
如何改进我的语法以排除具有 1 位或 2 位或 3 位数字的最新数字?
所以我们得到这样的输出
1623222654527
1623222654679
1623222654744
Run Code Online (Sandbox Code Playgroud)
像这样?:
$ awk -F_ 'length($NF)>3{print $NF}' file
Run Code Online (Sandbox Code Playgroud)
输出:
1623222654527
1623222654679
1623222654744
Run Code Online (Sandbox Code Playgroud)
以_字段分隔符,如果最后一个字段的长度$NF大于3,则输出最后一个字段。