0
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.

link > grep > Binary fiile ***.cpp matches > grep -aで実行する

Last updated at Posted at 2017-10-25
動作環境
Windows 7 Pro (32bit)
SmartGit Version 17.0.4 #10132
SmartGit付属のMinGW32
grep (GNU grep) 2.24
head (GNU coreutils) 8.25

C++ Builderで実装している.cppファイルをMinGW32上でgrepした。

$ grep kSecond *.cpp
Binary file XXX.cpp matches

.cppファイルなので、バイナリファイルではないが、バイナリファイルと認識されてしまう。

対策としては、r_nobuさんの情報が参考になりました。
http://nobuneko.com/blog/archives/2013/04/linux_grep_binary_files_text.html

→grep対象のファイルをバイナリファイルではなく、テキストファイルとして扱いたい場合は、grepコマンドに「-a」、「--text」、「--binary-files=text」といったオプションを付与すればよい。

情報感謝です。

$ grep -a kSecond *.cpp
XXX.cpp: static const int kSecond_notify_shutdown = 70;

予備情報

grepの検索対象を70とした場合は、バイナリファイルとして認識されずに内容が表示された。

$ grep 70 *.cpp
XXX.cpp: static const int kSecond_notify_shutdown = 70;
0
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
0
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?