我有一个文件
cat /tmp/b
A
Quick
Brown
Fox
Killed
2 Hens
如果我匹配[0-9]
然后我得到预期
cat /tmp/b | grep "[0-9]"
2 Hens
但是,如果我尝试匹配数字字符类,我会得到意想不到的结果
cat /tmp/b | grep "\d"
Killed
无论我认为我尝试哪种组合方式,这种情况都会继续
cat /tmp/b | grep "\\d"
Killed
cat /tmp/b | grep "\\d"
Killed
cat /tmp/b | grep "\\\\d"
{No matches}
cat /tmp/b | grep "\\\d"
{No matches}
cat /tmp/b | grep "[\\d]"
Killed
cat /tmp/b | grep "[d]"
Killed
cat /tmp/b | grep "[\\\\d]"
Killed
有谁知道我做错了什么以及如何让 Character Classed 在 cygwin sed 中工作
更新
cat /tmp/b | grep [:digit]
Quick
Killed
更新 2
cat /tmp/b | grep [[:digit:]]
2 Hens