xref: /freebsd/usr.bin/stat/stat.1 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
14221d3ebSDoug Barton.\"	$NetBSD: stat.1,v 1.28 2010/04/05 21:25:01 joerg Exp $
206b6d7d8SDoug Barton.\"
306b6d7d8SDoug Barton.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
406b6d7d8SDoug Barton.\" All rights reserved.
506b6d7d8SDoug Barton.\"
606b6d7d8SDoug Barton.\" This code is derived from software contributed to The NetBSD Foundation
706b6d7d8SDoug Barton.\" by Andrew Brown and Jan Schaumann.
806b6d7d8SDoug Barton.\"
906b6d7d8SDoug Barton.\" Redistribution and use in source and binary forms, with or without
1006b6d7d8SDoug Barton.\" modification, are permitted provided that the following conditions
1106b6d7d8SDoug Barton.\" are met:
1206b6d7d8SDoug Barton.\" 1. Redistributions of source code must retain the above copyright
1306b6d7d8SDoug Barton.\"    notice, this list of conditions and the following disclaimer.
1406b6d7d8SDoug Barton.\" 2. Redistributions in binary form must reproduce the above copyright
1506b6d7d8SDoug Barton.\"    notice, this list of conditions and the following disclaimer in the
1606b6d7d8SDoug Barton.\"    documentation and/or other materials provided with the distribution.
1706b6d7d8SDoug Barton.\"
1806b6d7d8SDoug Barton.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1906b6d7d8SDoug Barton.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2006b6d7d8SDoug Barton.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2106b6d7d8SDoug Barton.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2206b6d7d8SDoug Barton.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2306b6d7d8SDoug Barton.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2406b6d7d8SDoug Barton.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2506b6d7d8SDoug Barton.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2606b6d7d8SDoug Barton.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2706b6d7d8SDoug Barton.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2806b6d7d8SDoug Barton.\" POSSIBILITY OF SUCH DAMAGE.
2906b6d7d8SDoug Barton.\"
3021860bf9SEnji Cooper.Dd June 22, 2017
3106b6d7d8SDoug Barton.Dt STAT 1
3206b6d7d8SDoug Barton.Os
3306b6d7d8SDoug Barton.Sh NAME
345b812a14SDoug Barton.Nm stat ,
355b812a14SDoug Barton.Nm readlink
3606b6d7d8SDoug Barton.Nd display file status
3706b6d7d8SDoug Barton.Sh SYNOPSIS
3806b6d7d8SDoug Barton.Nm
394d6bab26SThomas Quinot.Op Fl FHLnq
40f937c268SRuslan Ermilov.Op Fl f Ar format | Fl l | r | s | x
4106b6d7d8SDoug Barton.Op Fl t Ar timefmt
4206b6d7d8SDoug Barton.Op Ar
435b812a14SDoug Barton.Nm readlink
44d29003e7SDoug Barton.Op Fl fn
455b812a14SDoug Barton.Op Ar
4606b6d7d8SDoug Barton.Sh DESCRIPTION
4706b6d7d8SDoug BartonThe
4806b6d7d8SDoug Barton.Nm
4906b6d7d8SDoug Bartonutility displays information about the file pointed to by
5006b6d7d8SDoug Barton.Ar file .
51d127a98cSDoug BartonRead, write, or execute permissions of the named file are not required, but
5206b6d7d8SDoug Bartonall directories listed in the pathname leading to the file must be
53fd52243cSDoug Bartonsearchable.
54fd52243cSDoug BartonIf no argument is given,
5506b6d7d8SDoug Barton.Nm
5606b6d7d8SDoug Bartondisplays information about the file descriptor for standard input.
5706b6d7d8SDoug Barton.Pp
585b812a14SDoug BartonWhen invoked as
595b812a14SDoug Barton.Nm readlink ,
60fd52243cSDoug Bartononly the target of the symbolic link is printed.
61d29003e7SDoug BartonIf the given argument is not a symbolic link and the
62d29003e7SDoug Barton.Fl f
63d29003e7SDoug Bartonoption is not specified,
645b812a14SDoug Barton.Nm readlink
655b812a14SDoug Bartonwill print nothing and exit with an error.
66d29003e7SDoug BartonIf the
67d29003e7SDoug Barton.Fl f
68d29003e7SDoug Bartonoption is specified, the output is canonicalized by following every symlink
69d29003e7SDoug Bartonin every component of the given path recursively.
70d29003e7SDoug Barton.Nm readlink
71d29003e7SDoug Bartonwill resolve both absolute and relative paths, and return the absolute pathname
72d29003e7SDoug Bartoncorresponding to
73d29003e7SDoug Barton.Ar file .
74d29003e7SDoug BartonIn this case, the argument does not need to be a symbolic link.
755b812a14SDoug Barton.Pp
7606b6d7d8SDoug BartonThe information displayed is obtained by calling
7706b6d7d8SDoug Barton.Xr lstat 2
7806b6d7d8SDoug Bartonwith the given argument and evaluating the returned structure.
79c6281ac0SDoug BartonThe default format displays the
80c6281ac0SDoug Barton.Fa st_dev ,
81c6281ac0SDoug Barton.Fa st_ino ,
82c6281ac0SDoug Barton.Fa st_mode ,
83c6281ac0SDoug Barton.Fa st_nlink ,
84c6281ac0SDoug Barton.Fa st_uid ,
85c6281ac0SDoug Barton.Fa st_gid ,
86c6281ac0SDoug Barton.Fa st_rdev ,
87c6281ac0SDoug Barton.Fa st_size ,
88c6281ac0SDoug Barton.Fa st_atime ,
89c6281ac0SDoug Barton.Fa st_mtime ,
90c6281ac0SDoug Barton.Fa st_ctime ,
91c6281ac0SDoug Barton.Fa st_birthtime ,
92c6281ac0SDoug Barton.Fa st_blksize ,
93c6281ac0SDoug Barton.Fa st_blocks ,
94c6281ac0SDoug Bartonand
95c6281ac0SDoug Barton.Fa st_flags
96c6281ac0SDoug Bartonfields, in that order.
9706b6d7d8SDoug Barton.Pp
9806b6d7d8SDoug BartonThe options are as follows:
99f937c268SRuslan Ermilov.Bl -tag -width indent
10006b6d7d8SDoug Barton.It Fl F
10106b6d7d8SDoug BartonAs in
102f937c268SRuslan Ermilov.Xr ls 1 ,
103f937c268SRuslan Ermilovdisplay a slash
104f937c268SRuslan Ermilov.Pq Ql /
105f937c268SRuslan Ermilovimmediately after each pathname that is a directory,
106f937c268SRuslan Ermilovan asterisk
107f937c268SRuslan Ermilov.Pq Ql *
108f937c268SRuslan Ermilovafter each that is executable,
109f937c268SRuslan Ermilovan at sign
110f937c268SRuslan Ermilov.Pq Ql @
111f937c268SRuslan Ermilovafter each symbolic link,
112f937c268SRuslan Ermilova percent sign
113f937c268SRuslan Ermilov.Pq Ql %
114f937c268SRuslan Ermilovafter each whiteout,
115f937c268SRuslan Ermilovan equal sign
116f937c268SRuslan Ermilov.Pq Ql =
117f937c268SRuslan Ermilovafter each socket,
118f937c268SRuslan Ermilovand a vertical bar
119f937c268SRuslan Ermilov.Pq Ql |
120f937c268SRuslan Ermilovafter each that is a FIFO.
121fd52243cSDoug BartonThe use of
12206b6d7d8SDoug Barton.Fl F
12306b6d7d8SDoug Bartonimplies
12406b6d7d8SDoug Barton.Fl l .
1254d6bab26SThomas Quinot.It Fl H
1264d6bab26SThomas QuinotTreat each argument as the hexadecimal representation of an NFS file handle,
1274d6bab26SThomas Quinotand use
1284d6bab26SThomas Quinot.Xr fhstat 2
1294d6bab26SThomas Quinotinstead of
1304d6bab26SThomas Quinot.Xr lstat 2 .
13155298f03SThomas QuinotThis requires root privileges.
13206b6d7d8SDoug Barton.It Fl L
13306b6d7d8SDoug BartonUse
13406b6d7d8SDoug Barton.Xr stat 2
13506b6d7d8SDoug Bartoninstead of
13606b6d7d8SDoug Barton.Xr lstat 2 .
13706b6d7d8SDoug BartonThe information reported by
13806b6d7d8SDoug Barton.Nm
13906b6d7d8SDoug Bartonwill refer to the target of
14006b6d7d8SDoug Barton.Ar file ,
14106b6d7d8SDoug Bartonif file is a symbolic link, and not to
14206b6d7d8SDoug Barton.Ar file
14306b6d7d8SDoug Bartonitself.
1445c06c8a1SDoug BartonIf the link is broken or the target does not exist,
1455c06c8a1SDoug Bartonfall back on
1465c06c8a1SDoug Barton.Xr lstat 2
1475c06c8a1SDoug Bartonand report information about the link.
14806b6d7d8SDoug Barton.It Fl n
14906b6d7d8SDoug BartonDo not force a newline to appear at the end of each piece of output.
150a6d19295SDoug Barton.It Fl q
151a6d19295SDoug BartonSuppress failure messages if calls to
152a6d19295SDoug Barton.Xr stat 2
153a6d19295SDoug Bartonor
154a6d19295SDoug Barton.Xr lstat 2
155a6d19295SDoug Bartonfail.
156a6d19295SDoug BartonWhen run as
157a6d19295SDoug Barton.Nm readlink ,
158a6d19295SDoug Bartonerror messages are automatically suppressed.
15906b6d7d8SDoug Barton.It Fl f Ar format
160fd52243cSDoug BartonDisplay information using the specified format.
161fa7f4291SRuslan ErmilovSee the
162f1025ba7SPawel Jakub Dawidek.Sx Formats
163fa7f4291SRuslan Ermilovsection for a description of valid formats.
16406b6d7d8SDoug Barton.It Fl l
16506b6d7d8SDoug BartonDisplay output in
166f937c268SRuslan Ermilov.Nm ls Fl lT
16706b6d7d8SDoug Bartonformat.
16806b6d7d8SDoug Barton.It Fl r
169fd52243cSDoug BartonDisplay raw information.
170f937c268SRuslan ErmilovThat is, for all the fields in the
171f937c268SRuslan Ermilov.Vt stat
172f937c268SRuslan Ermilovstructure,
17306b6d7d8SDoug Bartondisplay the raw, numerical value (for example, times in seconds since the
174f937c268SRuslan Ermilovepoch, etc.).
17506b6d7d8SDoug Barton.It Fl s
176f937c268SRuslan ErmilovDisplay information in
177d127a98cSDoug Barton.Dq shell output
178d127a98cSDoug Bartonformat,
179f937c268SRuslan Ermilovsuitable for initializing variables.
18006b6d7d8SDoug Barton.It Fl t Ar timefmt
181fd52243cSDoug BartonDisplay timestamps using the specified format.
182fd52243cSDoug BartonThis format is
18306b6d7d8SDoug Bartonpassed directly to
18406b6d7d8SDoug Barton.Xr strftime 3 .
185*39aed6d6SEnji Cooper.It Fl x
186*39aed6d6SEnji CooperDisplay information in a more verbose way as known from some
187*39aed6d6SEnji Cooper.Tn Linux
188*39aed6d6SEnji Cooperdistributions.
18906b6d7d8SDoug Barton.El
190f937c268SRuslan Ermilov.Ss Formats
19106b6d7d8SDoug BartonFormat strings are similar to
19206b6d7d8SDoug Barton.Xr printf 3
19306b6d7d8SDoug Bartonformats in that they start with
19406b6d7d8SDoug Barton.Cm % ,
19506b6d7d8SDoug Bartonare then followed by a sequence of formatting characters, and end in
196f937c268SRuslan Ermilova character that selects the field of the
197f937c268SRuslan Ermilov.Vt "struct stat"
198f937c268SRuslan Ermilovwhich is to be formatted.
199fd52243cSDoug BartonIf the
20006b6d7d8SDoug Barton.Cm %
20106b6d7d8SDoug Bartonis immediately followed by one of
202f937c268SRuslan Ermilov.Cm n , t , % ,
20306b6d7d8SDoug Bartonor
20406b6d7d8SDoug Barton.Cm @ ,
20506b6d7d8SDoug Bartonthen a newline character, a tab character, a percent character,
20606b6d7d8SDoug Bartonor the current file number is printed, otherwise the string is
20706b6d7d8SDoug Bartonexamined for the following:
20806b6d7d8SDoug Barton.Pp
20906b6d7d8SDoug BartonAny of the following optional flags:
210f937c268SRuslan Ermilov.Bl -tag -width indent
21106b6d7d8SDoug Barton.It Cm #
21206b6d7d8SDoug BartonSelects an alternate output form for octal and hexadecimal output.
21306b6d7d8SDoug BartonNon-zero octal output will have a leading zero, and non-zero
214f937c268SRuslan Ermilovhexadecimal output will have
215f937c268SRuslan Ermilov.Dq Li 0x
216f937c268SRuslan Ermilovprepended to it.
21706b6d7d8SDoug Barton.It Cm +
21806b6d7d8SDoug BartonAsserts that a sign indicating whether a number is positive or negative
219fd52243cSDoug Bartonshould always be printed.
220fd52243cSDoug BartonNon-negative numbers are not usually printed
22106b6d7d8SDoug Bartonwith a sign.
22206b6d7d8SDoug Barton.It Cm -
22306b6d7d8SDoug BartonAligns string output to the left of the field, instead of to the right.
22406b6d7d8SDoug Barton.It Cm 0
225f937c268SRuslan ErmilovSets the fill character for left padding to the
226f937c268SRuslan Ermilov.Ql 0
227f937c268SRuslan Ermilovcharacter, instead of a space.
22806b6d7d8SDoug Barton.It space
229fd52243cSDoug BartonReserves a space at the front of non-negative signed output fields.
230fd52243cSDoug BartonA
23106b6d7d8SDoug Barton.Sq Cm +
23206b6d7d8SDoug Bartonoverrides a space if both are used.
23306b6d7d8SDoug Barton.El
23406b6d7d8SDoug Barton.Pp
23506b6d7d8SDoug BartonThen the following fields:
236f937c268SRuslan Ermilov.Bl -tag -width indent
237f937c268SRuslan Ermilov.It Ar size
23806b6d7d8SDoug BartonAn optional decimal digit string specifying the minimum field width.
239f937c268SRuslan Ermilov.It Ar prec
24006b6d7d8SDoug BartonAn optional precision composed of a decimal point
24106b6d7d8SDoug Barton.Sq Cm \&.
24206b6d7d8SDoug Bartonand a decimal digit string that indicates the maximum string length,
24306b6d7d8SDoug Bartonthe number of digits to appear after the decimal point in floating point
24406b6d7d8SDoug Bartonoutput, or the minimum number of digits to appear in numeric output.
245f937c268SRuslan Ermilov.It Ar fmt
24606b6d7d8SDoug BartonAn optional output format specifier which is one of
247f937c268SRuslan Ermilov.Cm D , O , U , X , F ,
24806b6d7d8SDoug Bartonor
24906b6d7d8SDoug Barton.Cm S .
25006b6d7d8SDoug BartonThese represent signed decimal output, octal output, unsigned decimal
25106b6d7d8SDoug Bartonoutput, hexadecimal output, floating point output, and string output,
252fd52243cSDoug Bartonrespectively.
253fd52243cSDoug BartonSome output formats do not apply to all fields.
254f937c268SRuslan ErmilovFloating point output only applies to
255f937c268SRuslan Ermilov.Vt timespec
256f937c268SRuslan Ermilovfields (the
257f937c268SRuslan Ermilov.Cm a , m ,
25806b6d7d8SDoug Bartonand
25906b6d7d8SDoug Barton.Cm c
26006b6d7d8SDoug Bartonfields).
26106b6d7d8SDoug Barton.Pp
26206b6d7d8SDoug BartonThe special output specifier
26306b6d7d8SDoug Barton.Cm S
26406b6d7d8SDoug Bartonmay be used to indicate that the output, if
265fd52243cSDoug Bartonapplicable, should be in string format.
266f937c268SRuslan ErmilovMay be used in combination with:
267f937c268SRuslan Ermilov.Bl -tag -width indent
26806b6d7d8SDoug Barton.It Cm amc
269f937c268SRuslan ErmilovDisplay date in
270f937c268SRuslan Ermilov.Xr strftime 3
271f937c268SRuslan Ermilovformat.
27206b6d7d8SDoug Barton.It Cm dr
27306b6d7d8SDoug BartonDisplay actual device name.
27424d9be57SJilles Tjoelker.It Cm f
27524d9be57SJilles TjoelkerDisplay the flags of
27624d9be57SJilles Tjoelker.Ar file
27724d9be57SJilles Tjoelkeras in
27824d9be57SJilles Tjoelker.Nm ls Fl lTdo .
27906b6d7d8SDoug Barton.It Cm gu
28006b6d7d8SDoug BartonDisplay group or user name.
28106b6d7d8SDoug Barton.It Cm p
28206b6d7d8SDoug BartonDisplay the mode of
28306b6d7d8SDoug Barton.Ar file
28406b6d7d8SDoug Bartonas in
285f937c268SRuslan Ermilov.Nm ls Fl lTd .
28606b6d7d8SDoug Barton.It Cm N
28706b6d7d8SDoug BartonDisplays the name of
28806b6d7d8SDoug Barton.Ar file .
28906b6d7d8SDoug Barton.It Cm T
29006b6d7d8SDoug BartonDisplays the type of
29106b6d7d8SDoug Barton.Ar file .
29206b6d7d8SDoug Barton.It Cm Y
293f937c268SRuslan ErmilovInsert a
294f937c268SRuslan Ermilov.Dq Li " -\*[Gt] "
295f937c268SRuslan Ermilovinto the output.
296fd52243cSDoug BartonNote that the default output format
29706b6d7d8SDoug Bartonfor
29806b6d7d8SDoug Barton.Cm Y
29906b6d7d8SDoug Bartonis a string, but if specified explicitly, these four characters are
30006b6d7d8SDoug Bartonprepended.
30106b6d7d8SDoug Barton.El
302f937c268SRuslan Ermilov.It Ar sub
303fd52243cSDoug BartonAn optional sub field specifier (high, middle, low).
304fd52243cSDoug BartonOnly applies to
30506b6d7d8SDoug Bartonthe
306f937c268SRuslan Ermilov.Cm p , d , r ,
30706b6d7d8SDoug Bartonand
30806b6d7d8SDoug Barton.Cm T
309fd52243cSDoug Bartonoutput formats.
310fd52243cSDoug BartonIt can be one of the following:
311f937c268SRuslan Ermilov.Bl -tag -width indent
31206b6d7d8SDoug Barton.It Cm H
313f937c268SRuslan Ermilov.Dq High
314f937c268SRuslan Ermilov\[em]
315f937c268SRuslan Ermilovspecifies the major number for devices from
31606b6d7d8SDoug Barton.Cm r
31706b6d7d8SDoug Bartonor
31806b6d7d8SDoug Barton.Cm d ,
319f937c268SRuslan Ermilovthe
320f937c268SRuslan Ermilov.Dq user
321f937c268SRuslan Ermilovbits for permissions from the string form of
32206b6d7d8SDoug Barton.Cm p ,
323f937c268SRuslan Ermilovthe file
324f937c268SRuslan Ermilov.Dq type
325f937c268SRuslan Ermilovbits from the numeric forms of
32606b6d7d8SDoug Barton.Cm p ,
32706b6d7d8SDoug Bartonand the long output form of
32806b6d7d8SDoug Barton.Cm T .
32906b6d7d8SDoug Barton.It Cm L
330f937c268SRuslan Ermilov.Dq Low
331f937c268SRuslan Ermilov\[em]
332f937c268SRuslan Ermilovspecifies the minor number for devices from
33306b6d7d8SDoug Barton.Cm r
33406b6d7d8SDoug Bartonor
33506b6d7d8SDoug Barton.Cm d ,
336f937c268SRuslan Ermilovthe
337f937c268SRuslan Ermilov.Dq other
338f937c268SRuslan Ermilovbits for permissions from the string form of
33906b6d7d8SDoug Barton.Cm p ,
340f937c268SRuslan Ermilovthe
341f937c268SRuslan Ermilov.Dq user ,
342f937c268SRuslan Ermilov.Dq group ,
343f937c268SRuslan Ermilovand
344f937c268SRuslan Ermilov.Dq other
345f937c268SRuslan Ermilovbits from the numeric forms of
34606b6d7d8SDoug Barton.Cm p ,
34706b6d7d8SDoug Bartonand the
348f937c268SRuslan Ermilov.Nm ls Fl F
34906b6d7d8SDoug Bartonstyle output character for file type when used with
35006b6d7d8SDoug Barton.Cm T
35106b6d7d8SDoug Barton(the use of
35206b6d7d8SDoug Barton.Cm L
35306b6d7d8SDoug Bartonfor this is optional).
35406b6d7d8SDoug Barton.It Cm M
355f937c268SRuslan Ermilov.Dq Middle
356f937c268SRuslan Ermilov\[em]
357f937c268SRuslan Ermilovspecifies the
358f937c268SRuslan Ermilov.Dq group
359f937c268SRuslan Ermilovbits for permissions from the
36006b6d7d8SDoug Bartonstring output form of
36106b6d7d8SDoug Barton.Cm p ,
362f937c268SRuslan Ermilovor the
363f937c268SRuslan Ermilov.Dq suid ,
364f937c268SRuslan Ermilov.Dq sgid ,
365f937c268SRuslan Ermilovand
366f937c268SRuslan Ermilov.Dq sticky
367f937c268SRuslan Ermilovbits for the numeric forms of
36806b6d7d8SDoug Barton.Cm p .
36906b6d7d8SDoug Barton.El
370f937c268SRuslan Ermilov.It Ar datum
37106b6d7d8SDoug BartonA required field specifier, being one of the following:
372f937c268SRuslan Ermilov.Bl -tag -width indent
37306b6d7d8SDoug Barton.It Cm d
37406b6d7d8SDoug BartonDevice upon which
37506b6d7d8SDoug Barton.Ar file
376c6281ac0SDoug Bartonresides
377c6281ac0SDoug Barton.Pq Fa st_dev .
37806b6d7d8SDoug Barton.It Cm i
379f937c268SRuslan Ermilov.Ar file Ns 's
380c6281ac0SDoug Bartoninode number
381c6281ac0SDoug Barton.Pq Fa st_ino .
38206b6d7d8SDoug Barton.It Cm p
383c6281ac0SDoug BartonFile type and permissions
384c6281ac0SDoug Barton.Pq Fa st_mode .
38506b6d7d8SDoug Barton.It Cm l
38606b6d7d8SDoug BartonNumber of hard links to
387c6281ac0SDoug Barton.Ar file
388c6281ac0SDoug Barton.Pq Fa st_nlink .
38906b6d7d8SDoug Barton.It Cm u , g
390f937c268SRuslan ErmilovUser ID and group ID of
391f937c268SRuslan Ermilov.Ar file Ns 's
392c6281ac0SDoug Bartonowner
393c6281ac0SDoug Barton.Pq Fa st_uid , st_gid .
39406b6d7d8SDoug Barton.It Cm r
395c6281ac0SDoug BartonDevice number for character and block device special files
396c6281ac0SDoug Barton.Pq Fa st_rdev .
397fd52243cSDoug Barton.It Cm a , m , c , B
39806b6d7d8SDoug BartonThe time
39906b6d7d8SDoug Barton.Ar file
4007c304a3bSDoug Bartonwas last accessed or modified, or when the inode was last changed, or
401c6281ac0SDoug Bartonthe birth time of the inode
402c6281ac0SDoug Barton.Pq Fa st_atime , st_mtime , st_ctime , st_birthtime .
40306b6d7d8SDoug Barton.It Cm z
40406b6d7d8SDoug BartonThe size of
40506b6d7d8SDoug Barton.Ar file
406c6281ac0SDoug Bartonin bytes
407c6281ac0SDoug Barton.Pq Fa st_size .
40806b6d7d8SDoug Barton.It Cm b
40906b6d7d8SDoug BartonNumber of blocks allocated for
410c6281ac0SDoug Barton.Ar file
411c6281ac0SDoug Barton.Pq Fa st_blocks .
41206b6d7d8SDoug Barton.It Cm k
413c6281ac0SDoug BartonOptimal file system I/O operation block size
414c6281ac0SDoug Barton.Pq Fa st_blksize .
41506b6d7d8SDoug Barton.It Cm f
41606b6d7d8SDoug BartonUser defined flags for
41706b6d7d8SDoug Barton.Ar file .
41806b6d7d8SDoug Barton.It Cm v
419c6281ac0SDoug BartonInode generation number
420c6281ac0SDoug Barton.Pq Fa st_gen .
42106b6d7d8SDoug Barton.El
42206b6d7d8SDoug Barton.Pp
423d29003e7SDoug BartonThe following five field specifiers are not drawn directly from the
424f937c268SRuslan Ermilovdata in
425f937c268SRuslan Ermilov.Vt "struct stat" ,
426f937c268SRuslan Ermilovbut are:
427f937c268SRuslan Ermilov.Bl -tag -width indent
42806b6d7d8SDoug Barton.It Cm N
42906b6d7d8SDoug BartonThe name of the file.
430d29003e7SDoug Barton.It Cm R
431d29003e7SDoug BartonThe absolute pathname corresponding to the file.
43206b6d7d8SDoug Barton.It Cm T
43306b6d7d8SDoug BartonThe file type, either as in
434f937c268SRuslan Ermilov.Nm ls Fl F
435f937c268SRuslan Ermilovor in a more descriptive form if the
436f937c268SRuslan Ermilov.Ar sub
437f937c268SRuslan Ermilovfield specifier
43806b6d7d8SDoug Barton.Cm H
43906b6d7d8SDoug Bartonis given.
44006b6d7d8SDoug Barton.It Cm Y
44106b6d7d8SDoug BartonThe target of a symbolic link.
44206b6d7d8SDoug Barton.It Cm Z
443f937c268SRuslan ErmilovExpands to
444f937c268SRuslan Ermilov.Dq major,minor
445f937c268SRuslan Ermilovfrom the
446f937c268SRuslan Ermilov.Va rdev
447f937c268SRuslan Ermilovfield for character or block
44806b6d7d8SDoug Bartonspecial devices and gives size output for all others.
44906b6d7d8SDoug Barton.El
45006b6d7d8SDoug Barton.El
45106b6d7d8SDoug Barton.Pp
45206b6d7d8SDoug BartonOnly the
45306b6d7d8SDoug Barton.Cm %
454fd52243cSDoug Bartonand the field specifier are required.
455fd52243cSDoug BartonMost field specifiers default to
45606b6d7d8SDoug Barton.Cm U
45706b6d7d8SDoug Bartonas an output form, with the
45806b6d7d8SDoug Bartonexception of
45906b6d7d8SDoug Barton.Cm p
46006b6d7d8SDoug Bartonwhich defaults to
461dc5e1d52SDoug Barton.Cm O ;
46206b6d7d8SDoug Barton.Cm a , m ,
46306b6d7d8SDoug Bartonand
46406b6d7d8SDoug Barton.Cm c
46506b6d7d8SDoug Bartonwhich default to
466dc5e1d52SDoug Barton.Cm D ;
46706b6d7d8SDoug Bartonand
46806b6d7d8SDoug Barton.Cm Y , T ,
46906b6d7d8SDoug Bartonand
470f937c268SRuslan Ermilov.Cm N
47106b6d7d8SDoug Bartonwhich default to
47206b6d7d8SDoug Barton.Cm S .
47306b6d7d8SDoug Barton.Sh EXIT STATUS
474f937c268SRuslan Ermilov.Ex -std stat readlink
47506b6d7d8SDoug Barton.Sh EXAMPLES
476d127a98cSDoug BartonIf no options are specified, the default format is
4774221d3ebSDoug Barton"%d %i %Sp %l %Su %Sg %r %z \e"%Sa\e" \e"%Sm\e" \e"%Sc\e" \e"%SB\e" %k %b %#Xf %N".
4781c40e1f6SDoug Barton.Bd -literal -offset indent
4791c40e1f6SDoug Barton\*[Gt] stat /tmp/bar
4801c40e1f6SDoug Barton0 78852 -rw-r--r-- 1 root wheel 0 0 "Jul  8 10:26:03 2004" "Jul  8 10:26:03 2004" "Jul  8 10:28:13 2004" "Jan  1 09:00:00 1970" 16384 0 0 /tmp/bar
4811c40e1f6SDoug Barton.Ed
4821c40e1f6SDoug Barton.Pp
483f937c268SRuslan ErmilovGiven a symbolic link
484d127a98cSDoug Barton.Dq foo
485f937c268SRuslan Ermilovthat points from
486f937c268SRuslan Ermilov.Pa /tmp/foo
487f937c268SRuslan Ermilovto
488f937c268SRuslan Ermilov.Pa / ,
489f937c268SRuslan Ermilovyou would use
49006b6d7d8SDoug Barton.Nm
49106b6d7d8SDoug Bartonas follows:
49206b6d7d8SDoug Barton.Bd -literal -offset indent
49306b6d7d8SDoug Barton\*[Gt] stat -F /tmp/foo
49406b6d7d8SDoug Bartonlrwxrwxrwx 1 jschauma cs 1 Apr 24 16:37:28 2002 /tmp/foo@ -\*[Gt] /
49506b6d7d8SDoug Barton
49606b6d7d8SDoug Barton\*[Gt] stat -LF /tmp/foo
497fd52243cSDoug Bartondrwxr-xr-x 16 root wheel 512 Apr 19 10:57:54 2002 /tmp/foo/
49806b6d7d8SDoug Barton.Ed
49906b6d7d8SDoug Barton.Pp
500f937c268SRuslan ErmilovTo initialize some shell variables, you could use the
50106b6d7d8SDoug Barton.Fl s
50206b6d7d8SDoug Bartonflag as follows:
50306b6d7d8SDoug Barton.Bd -literal -offset indent
50406b6d7d8SDoug Barton\*[Gt] csh
50506b6d7d8SDoug Barton% eval set `stat -s .cshrc`
50606b6d7d8SDoug Barton% echo $st_size $st_mtimespec
50706b6d7d8SDoug Barton1148 1015432481
50806b6d7d8SDoug Barton
50906b6d7d8SDoug Barton\*[Gt] sh
51006b6d7d8SDoug Barton$ eval $(stat -s .profile)
51106b6d7d8SDoug Barton$ echo $st_size $st_mtimespec
51206b6d7d8SDoug Barton1148 1015432481
51306b6d7d8SDoug Barton.Ed
51406b6d7d8SDoug Barton.Pp
5152e7b6bffSBrian SomersIn order to get a list of file types including files pointed to if the
51606b6d7d8SDoug Bartonfile is a symbolic link, you could use the following format:
51706b6d7d8SDoug Barton.Bd -literal -offset indent
51806b6d7d8SDoug Barton$ stat -f "%N: %HT%SY" /tmp/*
51906b6d7d8SDoug Barton/tmp/bar: Symbolic Link -\*[Gt] /tmp/foo
52006b6d7d8SDoug Barton/tmp/output25568: Regular File
52106b6d7d8SDoug Barton/tmp/blah: Directory
52206b6d7d8SDoug Barton/tmp/foo: Symbolic Link -\*[Gt] /
52306b6d7d8SDoug Barton.Ed
52406b6d7d8SDoug Barton.Pp
52506b6d7d8SDoug BartonIn order to get a list of the devices, their types and the major and minor
52606b6d7d8SDoug Bartondevice numbers, formatted with tabs and linebreaks, you could use the
52706b6d7d8SDoug Bartonfollowing format:
52806b6d7d8SDoug Barton.Bd -literal -offset indent
52906b6d7d8SDoug Bartonstat -f "Name: %N%n%tType: %HT%n%tMajor: %Hr%n%tMinor: %Lr%n%n" /dev/*
53006b6d7d8SDoug Barton[...]
53106b6d7d8SDoug BartonName: /dev/wt8
53206b6d7d8SDoug Barton        Type: Block Device
53306b6d7d8SDoug Barton        Major: 3
53406b6d7d8SDoug Barton        Minor: 8
53506b6d7d8SDoug Barton
53606b6d7d8SDoug BartonName: /dev/zero
53706b6d7d8SDoug Barton        Type: Character Device
53806b6d7d8SDoug Barton        Major: 2
53906b6d7d8SDoug Barton        Minor: 12
54006b6d7d8SDoug Barton.Ed
54106b6d7d8SDoug Barton.Pp
54206b6d7d8SDoug BartonIn order to determine the permissions set on a file separately, you could use
54306b6d7d8SDoug Bartonthe following format:
54406b6d7d8SDoug Barton.Bd -literal -offset indent
54506b6d7d8SDoug Barton\*[Gt] stat -f "%Sp -\*[Gt] owner=%SHp group=%SMp other=%SLp" .
54606b6d7d8SDoug Bartondrwxr-xr-x -\*[Gt] owner=rwx group=r-x other=r-x
54706b6d7d8SDoug Barton.Ed
54806b6d7d8SDoug Barton.Pp
54906b6d7d8SDoug BartonIn order to determine the three files that have been modified most recently,
55006b6d7d8SDoug Bartonyou could use the following format:
55106b6d7d8SDoug Barton.Bd -literal -offset indent
55206b6d7d8SDoug Barton\*[Gt] stat -f "%m%t%Sm %N" /tmp/* | sort -rn | head -3 | cut -f2-
55306b6d7d8SDoug BartonApr 25 11:47:00 2002 /tmp/blah
55406b6d7d8SDoug BartonApr 25 10:36:34 2002 /tmp/bar
55506b6d7d8SDoug BartonApr 24 16:47:35 2002 /tmp/foo
55606b6d7d8SDoug Barton.Ed
5572e7b6bffSBrian Somers.Pp
5582e7b6bffSBrian SomersTo display a file's modification time:
5592e7b6bffSBrian Somers.Bd -literal -offset indent
5602e7b6bffSBrian Somers\*[Gt] stat -f %m /tmp/foo
5612e7b6bffSBrian Somers1177697733
5622e7b6bffSBrian Somers.Ed
5632e7b6bffSBrian Somers.Pp
5642e7b6bffSBrian SomersTo display the same modification time in a readable format:
5652e7b6bffSBrian Somers.Bd -literal -offset indent
5662e7b6bffSBrian Somers\*[Gt] stat -f %Sm /tmp/foo
5672e7b6bffSBrian SomersApr 27 11:15:33 2007
5682e7b6bffSBrian Somers.Ed
5692e7b6bffSBrian Somers.Pp
5702e7b6bffSBrian SomersTo display the same modification time in a readable and sortable format:
5712e7b6bffSBrian Somers.Bd -literal -offset indent
5722e7b6bffSBrian Somers\*[Gt] stat -f %Sm -t %Y%m%d%H%M%S /tmp/foo
5732e7b6bffSBrian Somers20070427111533
5742e7b6bffSBrian Somers.Ed
5752e7b6bffSBrian Somers.Pp
5762e7b6bffSBrian SomersTo display the same in UTC:
5772e7b6bffSBrian Somers.Bd -literal -offset indent
5782e7b6bffSBrian Somers\*[Gt] sh
5792e7b6bffSBrian Somers$ TZ= stat -f %Sm -t %Y%m%d%H%M%S /tmp/foo
5802e7b6bffSBrian Somers20070427181533
5812e7b6bffSBrian Somers.Ed
58206b6d7d8SDoug Barton.Sh SEE ALSO
58306b6d7d8SDoug Barton.Xr file 1 ,
58406b6d7d8SDoug Barton.Xr ls 1 ,
58506b6d7d8SDoug Barton.Xr lstat 2 ,
58606b6d7d8SDoug Barton.Xr readlink 2 ,
58706b6d7d8SDoug Barton.Xr stat 2 ,
58806b6d7d8SDoug Barton.Xr printf 3 ,
58906b6d7d8SDoug Barton.Xr strftime 3
59006b6d7d8SDoug Barton.Sh HISTORY
59106b6d7d8SDoug BartonThe
59206b6d7d8SDoug Barton.Nm
59306b6d7d8SDoug Bartonutility appeared in
594c0d08dc2SDavid E. O'Brien.Nx 1.6
595c0d08dc2SDavid E. O'Brienand
596c0d08dc2SDavid E. O'Brien.Fx 4.10 .
59706b6d7d8SDoug Barton.Sh AUTHORS
598f937c268SRuslan Ermilov.An -nosplit
59906b6d7d8SDoug BartonThe
60006b6d7d8SDoug Barton.Nm
601fd52243cSDoug Bartonutility was written by
6022b7af31cSBaptiste Daroussin.An Andrew Brown Aq Mt atatat@NetBSD.org .
603fd52243cSDoug BartonThis man page was written by
6042b7af31cSBaptiste Daroussin.An Jan Schaumann Aq Mt jschauma@NetBSD.org .
605