Python 或 sed 单行删除以任意数字开头且包含一个字符串的行

问题描述 投票:0回答:1

我想扩展here提供的答案,以便能够进行删除而不是替换,但到目前为止我还没有成功。预先感谢您的任何意见。

输入数据:

Test 1,2,3,
41
Test 5,6,7,
8800 
8800 8800 
8800.
8800.0
8,800
Test 9, 10
Test 11, 12

预期输出:

Test 1,2,3,
Test 5,6,7,
8800 8800 
8800.
8800.0
8,800
Test 9, 10
Test 11, 12
python regex perl text sed
1个回答
1
投票

使用

awk

$ awk '$0 !~ /^[0-9]+$/ {print $0}' file
Test 1,2,3,
Test 5,6,7,
8800 8800
8800.
8800.0
8,800
Test 9, 10
Test 11, 12
© www.soinside.com 2019 - 2024. All rights reserved.