\d 是否等于 sed 中的 [0-9]?

use*_*279 1 linux bash sed

7
00:00:30,008 --> 00:00:30,066
by line
8
00:00:31,038 --> 00:00:34,050
or later in the nineteen seventies it was usually a
9
00:00:34,005 --> 00:00:38,634^M
video consul but the council was not capable of displaying arbitrate graphics
10
Run Code Online (Sandbox Code Playgroud)

以上几行在一个名为 2.txt 的文件中。我想要不以数字开头的行。在实践中,sed -i '/^[0-9]+/d' 2.txt效果很好。然而,没有sed -i '/^\d+/d' 2.txt。\d 在正则表达式中不应该等于 [0-9] 吗?

gle*_*man 5

不。Sed 不使用与 Perl 兼容的正则表达式。GNU 工具的正则表达式支持记录在此处:https : //www.gnu.org/software/gnulib/manual/html_node/Regular-expression-syntaxes.html#Regular-expression-syntaxes

\d是性格d

你可以使用[[:digit:]]但不能\d