grep on word with colon 从命令输出中失败

grep on word with colon fails from command output

谁能解释为什么搜索 "artist" returns 结果,但搜索 "artist:" returns 什么都没有?

第一个结果:

MacBook-Pro:~ kjesso$ eyed3 ./Music/Deftones/2006\ -\ Saturday\ Night\ Wrist/Deftones\ -\ 02\ -\ Rapture.mp3
Deftones - 02 - Rapture.mp3 [ 5.26 MB ]
-------------------------------------------------------------------------------
Time: 03:25 MPEG1, Layer III    [ ~213 kb/s @ 44100 Hz - Joint stereo ]
-------------------------------------------------------------------------------
ID3 v2.3:
title: Rapture
artist: Deftones
album: Saturday Night Wrist
album artist: None
recording date: 2006
track: 2        genre: Rock (id 17)
Publisher/label: Maverick

第二个结果:

MacBook-Pro:~ kjesso$ eyed3 ./Music/Deftones/2006\ -\ Saturday\ Night\ Wrist/Deftones\ -\ 02\ -\ Rapture.mp3 | grep "artist"
artist: Deftones
album artist: None

第三个结果:

MacBook-Pro:~ kjesso$ eyed3 ./Music/Deftones/2006\ -\ Saturday\ Night\ Wrist/Deftones\ -\ 02\ -\ Rapture.mp3 | grep "artist:"

您确定您输入的第三个实例正确吗?它对我来说很好用:

$ cat foo.txt
Deftones - 02 - Rapture.mp3 [ 5.26 MB ]
-------------------------------------------------------------------------------
Time: 03:25 MPEG1, Layer III    [ ~213 kb/s @ 44100 Hz - Joint stereo ]
-------------------------------------------------------------------------------
ID3 v2.3:
title: Rapture
artist: Deftones
album: Saturday Night Wrist
album artist: None
recording date: 2006
track: 2        genre: Rock (id 17)
Publisher/label: Maverick

$ cat foo.txt | grep "artist"
artist: Deftones
album artist: None

$ cat foo.txt | grep "artist:"
artist: Deftones
album artist: None

也许您输入的是分号而不是冒号?

$ cat foo.txt | grep "artist;"
$

eyed3 添加了一些用于颜色编码的终端标记,因此输出中有一堆字节在您的终端上不可见但终端用于确定颜色编码 - 即使该颜色 -编码是“完全相同的颜色。

添加 --no-color 选项将完美运行:

$ eyed3 --no-color ./Music/Deftones/2006\ -\ Saturday\ Night\ Wrist/Deftones\ -\ 02\ -\ Rapture.mp3 | grep "artist:"