sed命令只过滤一组数字后跟逗号

时间:2016-04-21 11:19:32

标签: linux shell unix sed

我有一个看起来像这样的文件

0: jdbc:hive2://10.241.1.8:10000/> select number,exported_at from audit group by number,exported_at order by number limit 10;
789116704,20150907T130500Z
789190212,20150907T130500Z
789255093,20150907T130500Z
789282142,20150907T130500Z
789359510,20150907T130500Z
789363793,20150907T130500Z
789363843,20150907T130500Z
789369808,20150907T130500Z
789437014,20150907T130500Z
789437071,20150907T130500Z
0: jdbc:hive2://10.241.1.8:10000/>

我想只保留数字后跟逗号的行。即我的输出应该是这样的

    789116704,20150907T130500Z
    789190212,20150907T130500Z
    789255093,20150907T130500Z
    789282142,20150907T130500Z
    789359510,20150907T130500Z
    789363793,20150907T130500Z
    789363843,20150907T130500Z
    789369808,20150907T130500Z
    789437014,20150907T130500Z
    789437071,20150907T130500Z

我正在寻找可以完成这项工作的sed命令。任何帮助都非常感谢。感谢

2 个答案:

答案 0 :(得分:1)

grep -E '[0-9]+,' data.txt

其中data.txt是包含输入数据的文件

答案 1 :(得分:1)

你去吧

sed -n '/[0-9],/p' file