带有冒号的单词上的grep命令输出失败

时间:2016-08-03 19:59:13

标签: bash grep eyed3

任何人都可以解释为什么对“艺术家”的重击会返回结果,但是对“艺术家:”的追问会什么都不返回?

第一个结果:

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:"

2 个答案:

答案 0 :(得分:2)

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

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

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

答案 1 :(得分:0)

您确定正确键入了第三个实例吗?它对我很有用:

$ 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;"
$