what Command

Purpose

Displays identifying information in files.

Syntax

what [ -s] Pathname/File.

Description

The what command searches specified files for all occurrences of the pattern that the get command substitutes for the @(#) keyletter (see the get or prs command for a description of identification keywords). By convention, the value substituted is "@(#)" (double quotation marks, at sign, left parenthesis, pound sign, right parenthesis, double quotation marks). If no file is specified, the what command reads from standard input.

The what command writes to standard output whatever follows the pattern, up to but not including the first double quotation mark ("), greater than symbol (>), new-line character, backslash (\), or null character.

The what command should be used in conjunction with the get command, which automatically inserts the identifying information. You can also use the what command on files where the information is inserted manually.

The what command accommodates the compiler inserted command line options in a binary file. The command line options saved in a binary file by AIX® compilers may contain the backslash (\), the greater than symbol (>), or the double quotation mark ("), within the macro definitions. The what command behaves in the following manner to write the command line options saved by the compiler.

At the start of a line, if the pattern @(#) is followed by "opt" and is with or without a blank space (" ") in between, then the what command writes the character till "\n" that is the end of a line.

For example,
  • For C and FORTRAN AIX compilers, use @(#) opt (...).
  • For C++ AIX compilers, use @(#) opt (...).

The whole line is printed after "@(#)".

Note: The what command may fail to find SCCS identification strings in executable files.

Flags

Item Description
-s Searches for only the first occurrence of the @(#) pattern.

Exit Status

This command returns the following exit values:

Item Description
0 Any matches were found.
1 Otherwise.

Examples

Suppose that the file test.c contains a C program that includes the line:

char ident[ ] = "@(#)Test Program";

If you compile test.c to produce test.o, then the command:

what test.c test.o 

displays:

test.c:
Test Program
test.o:
Test Program
Note: The full file path names usr/bin/test.c and user/bin/test.o are required if the files are not in the current directory.

Files

Item Description
/usr/bin/what Contains the what command.