我无法捕捉每行的前 6 个字符。假设我在 text.txt 中有以下几行:
this is a sentence
1234567890
string
我想获得前 10 个字符:
this i
123456
string
我试过跑步grep -Eo "^[a-zA-Z0-9]*{6}" text.txt
但是 grep 在每 6 个位置回收正则表达式,而不是从下一个新行开始。它最终返回:
this i
s a se
ntence
123456
7890..
我在这里做错了什么?