为什么 grep 无法匹配等号?

为什么 grep 无法匹配等号?

这有效:

$ sudo gitlab-runner list 2>&1 | grep 'Token'
Python 2.7.14                                       Executor=docker Token=bccdbf31ef6bc74b2ae4980d8eccea URL=http://something
Docker                                              Executor=docker Token=5b06f034f48d3543848d7d209ce80c URL=http://something
Ansible                                             Executor=docker Token=e2215647f2c9981c8d74abaf324983 URL=http://something

这不:

$ sudo gitlab-runner list 2>&1 | grep 'Token='
(empty)

为什么?

我在用:

$ grep --version
grep (GNU grep) 2.25
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.

答案1

将上面的输出复制并粘贴到 grep Token= 中会直接传递这些行,因此 gitlab-runner 的输出中“Token”和“=”之间可能会有一些奇怪的无法打印的字符,这些字符已被您粘贴到 superuser.com 中清理干净。

相关内容