我想知道为什么 myfile.sed 中的搜索条件不会过滤。我只想过滤第一列中的任何 alpha。那就是我想在行首之后过滤任何 alpha,然后是一个字符并以一个字符和一个字符"
结尾,但是我在后续列中获取数据:"
,
我在用
sed -f myfile.sed in-file
myfile.sed 的内容看起来像
{
/^"[0-9]+[^0-9]+[0-9]*",/p
/^"[0-9]+",""/p
}
包含我要过滤的数据的文件内的前几个字段
"1866TL","1866TL","ME","SUBA","GRY","B","25","40","LAKEHILL AVE"
我有兴趣打印上面的行,因为非数字——TL——出现在第一列。
为了完成这项工作,我尝试将"
角色替换为[^0-9A-Za-z]
.
我试过只搜索几个数字后跟一个字符,但无法完成这项工作。
我究竟做错了什么?
从@choroba 的回答中将 myfile.sed 更正为如下所示:
{
/^"[0-9]\+[^0-9]\+[0-9]*",/p
/^"[0-9]\+",""/p
}
我正在获得其他我不打算获得的领域。如何切断逗号后的搜索?
"940915","L33677","MA","CHEV","RED","R","25","54","GROVE ST",
"1866TL","1866TL","ME","SUBA","GRY","B","25","40","LAKEHILL AVE",
"966011","1942758","NH","AUDI","BLU","","25","13","MT. VERNON ST.",