1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

grep > grep --color=always opt *.c | grep -v option > optionが除外されない理由

Posted at
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04.4 LTS desktop amd64
TensorFlow v1.7.0
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
scipy v0.19.1
geopandas v0.3.0
MATLAB R2017b (Home Edition)
ADDA v.1.3b6
gnustep-gui-runtime v0.24.0-3.1
PyMieScatt v1.7.0
GNU grep 2.25

症状

$ grep opt *.c | grep -v option
$ grep --color=always opt *.c | grep -v option

後者では結果にoptionも含まれる。何故か?

理由

参考: https://stackoverflow.com/questions/24093365/different-results-in-grep-results-when-using-color-always-option

以下と理解した。

  1. optionのoptにANSI escape codesが追加される
    • 例: at your ESC[01;31mESC[KoptESC[mESC[Kion) any later version.
  2. optionで除外しようにも、optionという文字列は1の時点で喪失している
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?