[9] | 1 | .TH STAT 1
|
---|
| 2 | .SH NAME
|
---|
| 3 | stat, lstat, readlink \- provide a shell interface to the stat(2) system call
|
---|
| 4 | .SH SYNOPSIS
|
---|
| 5 | .B stat
|
---|
| 6 | .RB [ - ]
|
---|
| 7 | .RB [ -\fIfd ]
|
---|
| 8 | .RB [ -all ]
|
---|
| 9 | .RB [ -s ]
|
---|
| 10 | .RB [ -\fIfield " ...]"
|
---|
| 11 | .RI [ file1 " ...]"
|
---|
| 12 | .SH DESCRIPTION
|
---|
| 13 | .B Stat
|
---|
| 14 | does little more than provide access to the fields in the
|
---|
| 15 | .B struct stat
|
---|
| 16 | as defined in the
|
---|
| 17 | .BR stat (2)
|
---|
| 18 | manual page. Each field that is to be listed
|
---|
| 19 | is specified as the field name without the leading
|
---|
| 20 | .BR st_ .
|
---|
| 21 | This and the other two options are described below. All options are then
|
---|
| 22 | applied to the files listed. If
|
---|
| 23 | .B stat
|
---|
| 24 | is called as
|
---|
| 25 | .B lstat
|
---|
| 26 | then the
|
---|
| 27 | .BR lstat (2)
|
---|
| 28 | system call is used, if called as
|
---|
| 29 | .B stat
|
---|
| 30 | symbolic links are expanded with
|
---|
| 31 | .BR stat (2).
|
---|
| 32 | If called as
|
---|
| 33 | .B readlink
|
---|
| 34 | then the output is only the contents of the symbolic link.
|
---|
| 35 | .PP
|
---|
| 36 | If no fields are named then all fields are printed. If no files are listed
|
---|
| 37 | then all open filedescriptors are printed.
|
---|
| 38 | .SH OPTIONS
|
---|
| 39 | .TP
|
---|
| 40 | .B \-
|
---|
| 41 | If the first argument is ``\-'', the list of files is assumed to come from stdin.
|
---|
| 42 | This is useful for things like ``ls | stat \-uid \-mtime.''
|
---|
| 43 | .B \-\fIfd
|
---|
| 44 | If an argument is a ``\-'' followed by a number then that number is used as
|
---|
| 45 | a file descriptor whose information is to be printed.
|
---|
| 46 | .TP
|
---|
| 47 | .B \-all
|
---|
| 48 | List all fields for each file.
|
---|
| 49 | .TP
|
---|
| 50 | .B \-s
|
---|
| 51 | Use
|
---|
| 52 | .BR lstat (2).
|
---|
| 53 | .TP
|
---|
| 54 | .B \-mode
|
---|
| 55 | List the
|
---|
| 56 | .B mode
|
---|
| 57 | field. Similarly for
|
---|
| 58 | .BR ino ,
|
---|
| 59 | .BR dev ,
|
---|
| 60 | .BR rdev ,
|
---|
| 61 | .BR nlink ,
|
---|
| 62 | .BR uid ,
|
---|
| 63 | .BR gid ,
|
---|
| 64 | .BR size ,
|
---|
| 65 | .BR atime ,
|
---|
| 66 | .BR mtime ,
|
---|
| 67 | and
|
---|
| 68 | .BR ctime .
|
---|
| 69 | Under BSD derived systems you also have
|
---|
| 70 | .B blksize
|
---|
| 71 | and
|
---|
| 72 | .BR blocks .
|
---|
| 73 | .PP
|
---|
| 74 | .B \-Atime
|
---|
| 75 | .br
|
---|
| 76 | .B \-Mtime
|
---|
| 77 | .br
|
---|
| 78 | .B \-Ctime
|
---|
| 79 | .RS
|
---|
| 80 | The lower case versions of these three options display the time as an integer
|
---|
| 81 | that is the ``seconds since 00:00 Jan 1. 1970.''
|
---|
| 82 | Listing the fields with the first letter
|
---|
| 83 | in caps causes the times to be printed in
|
---|
| 84 | .BR ctime (3)
|
---|
| 85 | format (i.e., human readable).
|
---|
| 86 | .RE
|
---|
| 87 | .SH EXAMPLES
|
---|
| 88 | .LP
|
---|
| 89 | # Find out the number of links to each file
|
---|
| 90 | .br
|
---|
| 91 | $ stat \-nlink *.c
|
---|
| 92 | .LP
|
---|
| 93 | # sort files by age (much like ls \-t)
|
---|
| 94 | .br
|
---|
| 95 | $ stat \-atime * | sort +1
|
---|
| 96 | .LP
|
---|
| 97 | # Find out which file is older in sh(1)
|
---|
| 98 | .br
|
---|
| 99 | if test `stat -mtime $1` -lt `stat -mtime $2`; then
|
---|
| 100 | .br
|
---|
| 101 | echo $1 is older than $2
|
---|
| 102 | .br
|
---|
| 103 | else
|
---|
| 104 | .br
|
---|
| 105 | echo $2 is older than $1
|
---|
| 106 | .br
|
---|
| 107 | fi
|
---|
| 108 | .SH "SEE ALSO"
|
---|
| 109 | .BR stat (2).
|
---|
| 110 | .SH AUTHOR
|
---|
| 111 | Larry McVoy (mcvoy@rsch.wisc.edu)
|
---|