In a terminal/console with a Unix shell (such as csh, tsh, bash, and so on), do the following:
- Create a simple program—for example,hello.c.
- Add the header file you want to find, and save it.
- In a bash command shell, execute the following:
cc -H hello.c 2>&1 | grep '^\.\ '
This command, which looks like a lot of gobbledegook, is doing the following:
- It invokes the compiler with the -H option. The list of header files is sent to stderr.
- 2>&1 redirects stderr to stdout.
- stdout is then redirected via a pipe (|) to grep, a regular expression parser.
- grep is told to search the beginning of each line for <period><space>:
- '…' is the search string.
- ^ indicates the beginning of a line.
- \. is a period (this is important as a dot (.) alone has special meaning in grep).
- \ is a space (this is important...