file—determines the type of a file by looking at its contents

file [[ –f ffile ] [ –cl ] [ –m mfile ] filename...

file performs a series of tests on each filename in an attempt to determine what it contains. If the contents of the file appear to be ASCII text, file examines the first 512 bytes and tries to guess its language.

Example A.21.
1   file bin/ls
    /bin/ls:sparc pure dynamically linked executable
2   file go
    go:    executable shell script
3   file junk
    junk:  English text
				

EXPLANATION

  1. ls is a binary file dynamically linked when executed.

  2. go is an executable shell script.

  3. junk is a file containing ASCII text.

Get UNIX® Shells by Example, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.