提问人:ee04395 提问时间:11/2/2023 最后编辑:ee04395 更新时间:11/3/2023 访问量:76
带正则表达式的 grep - 过滤包含连续相同数字并忽略空格的行
grep with regex - filter lines containing consecutive same number and ignoring whitespace
问:
包含多行字符串的文件 .txt
abc
abc1
abc11 11abc
abc111
abc abc1
我知道如何过滤包含 3 个或更多连续相同个位数的行
grep -E '([0-9])\1{2,}' file.txt
>> abc111
如何修改正则表达式,使其忽略空格并产生以下输出?
abc111
abc11 11abc
答:
评论
grep -E '([0-9]).*\1.*\1'
?111111
1
11