How can I exclude source file metadata from output

2019-08-03 04:19发布

问题:

For example:

$ gcc -O3 foobar.c -o foobar
$ grep 'foobar\.c' foobar
Binary file foobar matches

How can I exclude such unnecessary and revealing metadata from the output of gcc and other compilers? It appears regardless of whether the output is an assembly file, object file, or executable.

回答1:

man strip(1)

> strip -s a.out