Wed Sep 20 08:57:02 2017 UTC ()
whitespace fixes, use Xr.


(wiz)
diff -r1.39 -r1.40 src/usr.bin/stat/stat.1

cvs diff -r1.39 -r1.40 src/usr.bin/stat/stat.1 (switch to unified diff)

--- src/usr.bin/stat/stat.1 2017/09/19 21:45:28 1.39
+++ src/usr.bin/stat/stat.1 2017/09/20 08:57:02 1.40
@@ -1,636 +1,637 @@ @@ -1,636 +1,637 @@
1.\" $NetBSD: stat.1,v 1.39 2017/09/19 21:45:28 christos Exp $ 1.\" $NetBSD: stat.1,v 1.40 2017/09/20 08:57:02 wiz Exp $
2.\" 2.\"
3.\" Copyright (c) 2002-2011 The NetBSD Foundation, Inc. 3.\" Copyright (c) 2002-2011 The NetBSD Foundation, Inc.
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation 6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Andrew Brown and Jan Schaumann. 7.\" by Andrew Brown and Jan Schaumann.
8.\" 8.\"
9.\" Redistribution and use in source and binary forms, with or without 9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions 10.\" modification, are permitted provided that the following conditions
11.\" are met: 11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright 12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer. 13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in the 15.\" notice, this list of conditions and the following disclaimer in the
16.\" documentation and/or other materials provided with the distribution. 16.\" documentation and/or other materials provided with the distribution.
17.\" 17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE. 28.\" POSSIBILITY OF SUCH DAMAGE.
29.\" 29.\"
30.Dd September 19, 2017 30.Dd September 19, 2017
31.Dt STAT 1 31.Dt STAT 1
32.Os 32.Os
33.Sh NAME 33.Sh NAME
34.Nm stat , 34.Nm stat ,
35.Nm readlink 35.Nm readlink
36.Nd display file status 36.Nd display file status
37.Sh SYNOPSIS 37.Sh SYNOPSIS
38.Nm 38.Nm
39.Op Fl FLnq 39.Op Fl FLnq
40.Oo 40.Oo
41.Fl f Ar format | 41.Fl f Ar format |
42.Fl l | 42.Fl l |
43.Fl r | 43.Fl r |
44.Fl s | 44.Fl s |
45.Fl x 45.Fl x
46.Oc 46.Oc
47.Op Fl t Ar timefmt 47.Op Fl t Ar timefmt
48.Op Ar 48.Op Ar
49.Nm readlink 49.Nm readlink
50.Op Fl fnqsv 50.Op Fl fnqsv
51.Op Ar 51.Op Ar
52.Sh DESCRIPTION 52.Sh DESCRIPTION
53The 53The
54.Nm 54.Nm
55utility displays information about the file pointed to by 55utility displays information about the file pointed to by
56.Ar file . 56.Ar file .
57Read, write, or execute permissions of the named file are not required, but 57Read, write, or execute permissions of the named file are not required, but
58all directories listed in the pathname leading to the file must be 58all directories listed in the pathname leading to the file must be
59searchable. 59searchable.
60If no argument is given, 60If no argument is given,
61.Nm 61.Nm
62displays information about the file descriptor for standard input. 62displays information about the file descriptor for standard input.
63.Pp 63.Pp
64When invoked as 64When invoked as
65.Nm readlink , 65.Nm readlink ,
66only the target of the symbolic link is printed. 66only the target of the symbolic link is printed.
67If the given argument is not a symbolic link and the 67If the given argument is not a symbolic link and the
68.Fl f 68.Fl f
69option is not specified, 69option is not specified,
70.Nm readlink 70.Nm readlink
71will print nothing and exit with an error. 71will print nothing and exit with an error.
72If the 72If the
73.Fl f 73.Fl f
74option is specified, the output is canonicalized by following every symlink 74option is specified, the output is canonicalized by following every symlink
75in every component of the given path recursively. 75in every component of the given path recursively.
76.Nm readlink 76.Nm readlink
77will resolve both absolute and relative paths, and return the absolute pathname 77will resolve both absolute and relative paths, and return the absolute pathname
78corresponding to 78corresponding to
79.Ar file . 79.Ar file .
80In this case, the argument does not need to be a symbolic link. 80In this case, the argument does not need to be a symbolic link.
81.Pp 81.Pp
82The information displayed is obtained by calling 82The information displayed is obtained by calling
83.Xr lstat 2 83.Xr lstat 2
84with the given argument and evaluating the returned structure. 84with the given argument and evaluating the returned structure.
85The default format displays the 85The default format displays the
86.Fa st_dev , 86.Fa st_dev ,
87.Fa st_ino , 87.Fa st_ino ,
88.Fa st_mode , 88.Fa st_mode ,
89.Fa st_nlink , 89.Fa st_nlink ,
90.Fa st_uid , 90.Fa st_uid ,
91.Fa st_gid , 91.Fa st_gid ,
92.Fa st_rdev , 92.Fa st_rdev ,
93.Fa st_size , 93.Fa st_size ,
94.Fa st_atime , 94.Fa st_atime ,
95.Fa st_mtime , 95.Fa st_mtime ,
96.Fa st_ctime , 96.Fa st_ctime ,
97.Fa st_birthtime , 97.Fa st_birthtime ,
98.Fa st_blksize , 98.Fa st_blksize ,
99.Fa st_blocks , 99.Fa st_blocks ,
100and 100and
101.Fa st_flags 101.Fa st_flags
102fields, in that order. 102fields, in that order.
103.Pp 103.Pp
104The options are as follows: 104The options are as follows:
105.Bl -tag -width XFXformatXXX 105.Bl -tag -width XFXformatXXX
106.It Fl F 106.It Fl F
107As in 107As in
108.Xr ls 1 , 108.Xr ls 1 ,
109display a slash 109display a slash
110.Pq Sq / 110.Pq Sq /
111immediately after each pathname that is a directory, an 111immediately after each pathname that is a directory, an
112asterisk 112asterisk
113.Pq Sq * 113.Pq Sq *
114after each that is executable, an at sign 114after each that is executable, an at sign
115.Pq Sq @ 115.Pq Sq @
116after each symbolic link, a percent sign 116after each symbolic link, a percent sign
117.Pq Sq % 117.Pq Sq %
118after each whiteout, an equal sign 118after each whiteout, an equal sign
119.Pq Sq = 119.Pq Sq =
120after each socket, and a vertical bar 120after each socket, and a vertical bar
121.Pq Sq \&| 121.Pq Sq \&|
122after each that is a FIFO. 122after each that is a FIFO.
123The use of 123The use of
124.Fl F 124.Fl F
125implies 125implies
126.Fl l . 126.Fl l .
127.It Fl f Ar format 127.It Fl f Ar format
128Display information using the specified format. 128Display information using the specified format.
129See the 129See the
130.Sx FORMATS 130.Sx FORMATS
131section for a description of valid formats. 131section for a description of valid formats.
132.It Fl L 132.It Fl L
133Use 133Use
134.Xr stat 2 134.Xr stat 2
135instead of 135instead of
136.Xr lstat 2 . 136.Xr lstat 2 .
137The information reported by 137The information reported by
138.Nm 138.Nm
139will refer to the target of 139will refer to the target of
140.Ar file , 140.Ar file ,
141if file is a symbolic link, and not to 141if file is a symbolic link, and not to
142.Ar file 142.Ar file
143itself. 143itself.
144.It Fl l 144.It Fl l
145Display output in 145Display output in
146.Ic ls Fl lT 146.Ic ls Fl lT
147format. 147format.
148.It Fl n 148.It Fl n
149Do not force a newline to appear at the end of each piece of output. 149Do not force a newline to appear at the end of each piece of output.
150.It Fl q 150.It Fl q
151Suppress failure messages if calls to 151Suppress failure messages if calls to
152.Xr stat 2 152.Xr stat 2
153or 153or
154.Xr lstat 2 154.Xr lstat 2
155fail. 155fail.
156When run as 156When run as
157.Nm readlink , 157.Nm readlink ,
158error messages are automatically suppressed. 158error messages are automatically suppressed.
159.It Fl r 159.It Fl r
160Display raw information. 160Display raw information.
161That is, for all the fields in the stat-structure, 161That is, for all the fields in the stat-structure,
162display the raw, numerical value (for example, times in seconds since the 162display the raw, numerical value (for example, times in seconds since the
163epoch, etc.) 163epoch, etc.)
164.It Fl s 164.It Fl s
165Display information in 165Display information in
166.Dq shell output , 166.Dq shell output ,
167suitable for initializing variables. 167suitable for initializing variables.
168When run as 168When run as
169.Nm readlink , 169.Nm readlink ,
170suppress error messages. 170suppress error messages.
171This is equivalent to specifying 171This is equivalent to specifying
172.Bd -literal 172.Bd -literal
173FMT="st_dev=%d st_ino=%i st_mode=%#p st_nlink=%l st_uid=%u st_gid=%g" 173FMT="st_dev=%d st_ino=%i st_mode=%#p st_nlink=%l st_uid=%u st_gid=%g"
174FMT="$FMT st_rdev=%r st_size=%z st_atime=%Sa st_mtime=%Sm st_ctime=%Sc" 174FMT="$FMT st_rdev=%r st_size=%z st_atime=%Sa st_mtime=%Sm st_ctime=%Sc"
175FMT="$FMT st_birthtime=%SB st_blksize=%k st_blocks=%b st_flags=%f" 175FMT="$FMT st_birthtime=%SB st_blksize=%k st_blocks=%b st_flags=%f"
176stat -t %s -f "$FMT" . 176stat -t %s -f "$FMT" .
177.Ed 177.Ed
178Note that if you use a timeformat that contains embedded whitespace or shell 178Note that if you use a timeformat that contains embedded whitespace or shell
179meta-characters you will need to include appropriate quoting so the 179meta-characters you will need to include appropriate quoting so the
180.Fl s 180.Fl s
181output remains valid. 181output remains valid.
182.It Fl t Ar timefmt 182.It Fl t Ar timefmt
183Display timestamps using the specified format. 183Display timestamps using the specified format.
184This format is 184This format is
185passed directly to 185passed directly to
186.Xr strftime 3  186.Xr strftime 3
187with the extension that %f prints nanoseconds if available. 187with the extension that %f prints nanoseconds if available.
188.It Fl v 188.It Fl v
189Turn off quiet mode. 189Turn off quiet mode.
190.It Fl x 190.It Fl x
191Display information in a more verbose way as known from some Linux 191Display information in a more verbose way as known from some Linux
192distributions. 192distributions.
193.El 193.El
194.Ss FORMATS 194.Ss FORMATS
195Format strings are similar to 195Format strings are similar to
196.Xr printf 3 196.Xr printf 3
197formats in that they start with 197formats in that they start with
198.Cm % , 198.Cm % ,
199are then followed by a sequence of formatting characters, and end in 199are then followed by a sequence of formatting characters, and end in
200a character that selects the field of the struct stat which is to be 200a character that selects the field of the struct stat which is to be
201formatted. 201formatted.
202If the 202If the
203.Cm % 203.Cm %
204is immediately followed by one of 204is immediately followed by one of
205.Cm n , 205.Cm n ,
206.Cm t , 206.Cm t ,
207.Cm % , 207.Cm % ,
208or 208or
209.Cm @ , 209.Cm @ ,
210then a newline character, a tab character, a percent character, 210then a newline character, a tab character, a percent character,
211or the current file number is printed, otherwise the string is 211or the current file number is printed, otherwise the string is
212examined for the following: 212examined for the following:
213.Pp 213.Pp
214Any of the following optional flags: 214Any of the following optional flags:
215.Bl -tag -width Ds 215.Bl -tag -width Ds
216.It Cm # 216.It Cm #
217Selects an alternate output form for string, octal and hexadecimal output. 217Selects an alternate output form for string, octal and hexadecimal output.
218String output will be encoded in 218String output will be encoded in
219.Xr vis 3 219.Xr vis 3
220style. 220style.
221Non-zero octal output will have a leading zero. 221Non-zero octal output will have a leading zero.
222Non-zero hexadecimal output will have 222Non-zero hexadecimal output will have
223.Dq 0x 223.Dq 0x
224prepended to it. 224prepended to it.
225.It Cm + 225.It Cm +
226Asserts that a sign indicating whether a number is positive or negative 226Asserts that a sign indicating whether a number is positive or negative
227should always be printed. 227should always be printed.
228Non-negative numbers are not usually printed with a sign. 228Non-negative numbers are not usually printed with a sign.
229.It Cm - 229.It Cm -
230Aligns string output to the left of the field, instead of to the right. 230Aligns string output to the left of the field, instead of to the right.
231.It Cm 0 231.It Cm 0
232Sets the fill character for left padding to the 0 character, instead of 232Sets the fill character for left padding to the 0 character, instead of
233a space. 233a space.
234.It space 234.It space
235Reserves a space at the front of non-negative signed output fields. 235Reserves a space at the front of non-negative signed output fields.
236A 236A
237.Sq Cm + 237.Sq Cm +
238overrides a space if both are used. 238overrides a space if both are used.
239.El 239.El
240.Pp 240.Pp
241Then the following fields: 241Then the following fields:
242.Bl -tag -width Ds 242.Bl -tag -width Ds
243.It Cm size 243.It Cm size
244An optional decimal digit string specifying the minimum field width. 244An optional decimal digit string specifying the minimum field width.
245.It Cm prec 245.It Cm prec
246An optional precision composed of a decimal point 246An optional precision composed of a decimal point
247.Sq Cm \&. 247.Sq Cm \&.
248and a decimal digit string that indicates the maximum string length, 248and a decimal digit string that indicates the maximum string length,
249the number of digits to appear after the decimal point in floating point 249the number of digits to appear after the decimal point in floating point
250output, or the minimum number of digits to appear in numeric output. 250output, or the minimum number of digits to appear in numeric output.
251.It Cm fmt 251.It Cm fmt
252An optional output format specifier which is one of 252An optional output format specifier which is one of
253.Cm D , 253.Cm D ,
254.Cm O , 254.Cm O ,
255.Cm U , 255.Cm U ,
256.Cm X , 256.Cm X ,
257.Cm F , 257.Cm F ,
258or 258or
259.Cm S . 259.Cm S .
260These represent signed decimal output, octal output, unsigned decimal 260These represent signed decimal output, octal output, unsigned decimal
261output, hexadecimal output, floating point output, and string output, 261output, hexadecimal output, floating point output, and string output,
262respectively. 262respectively.
263Some output formats do not apply to all fields. 263Some output formats do not apply to all fields.
264Floating point output only applies to timespec fields (the 264Floating point output only applies to timespec fields (the
265.Cm a , 265.Cm a ,
266.Cm m , 266.Cm m ,
267and 267and
268.Cm c 268.Cm c
269fields). 269fields).
270.Pp 270.Pp
271The special output specifier 271The special output specifier
272.Cm S 272.Cm S
273may be used to indicate that the output, if 273may be used to indicate that the output, if
274applicable, should be in string format. 274applicable, should be in string format.
275May be used in combination with 275May be used in combination with
276.Bl -tag -width Ds 276.Bl -tag -width Ds
277.It Cm amc 277.It Cm amc
278Display date in strftime(3) format 278Display date in
279with the extension that %f prints nanoseconds if available. 279.Xr strftime 3
 280format with the extension that %f prints nanoseconds if available.
280.It Cm dr 281.It Cm dr
281Display actual device name. 282Display actual device name.
282.It Cm gu 283.It Cm gu
283Display group or user name. 284Display group or user name.
284.It Cm p 285.It Cm p
285Display the mode of 286Display the mode of
286.Ar file 287.Ar file
287as in 288as in
288.Ic ls -lTd . 289.Ic ls -lTd .
289.It Cm N 290.It Cm N
290Displays the name of 291Displays the name of
291.Ar file . 292.Ar file .
292.It Cm T 293.It Cm T
293Displays the type of 294Displays the type of
294.Ar file . 295.Ar file .
295.It Cm Y 296.It Cm Y
296Insert a `` -> '' into the output. 297Insert a `` -> '' into the output.
297Note that the default output format for 298Note that the default output format for
298.Cm Y 299.Cm Y
299is a string, but if specified explicitly, these four characters are 300is a string, but if specified explicitly, these four characters are
300prepended. 301prepended.
301.El 302.El
302.It Cm sub 303.It Cm sub
303An optional sub field specifier (high, middle, or low). 304An optional sub field specifier (high, middle, or low).
304Only applies to the 305Only applies to the
305.Cm p , 306.Cm p ,
306.Cm d , 307.Cm d ,
307.Cm r , 308.Cm r ,
308.Cm T , 309.Cm T ,
309.Cm N , 310.Cm N ,
310and 311and
311.Cm z 312.Cm z
312output formats. 313output formats.
313It can be one of the following: 314It can be one of the following:
314.Bl -tag -width Ds 315.Bl -tag -width Ds
315.It Cm H 316.It Cm H
316.Dq High 317.Dq High
317-- depending on the 318-- depending on the
318.Cm datum : 319.Cm datum :
319.Bl -tag -compact -width door 320.Bl -tag -compact -width door
320.It Cm d , r 321.It Cm d , r
321Major number for devices 322Major number for devices
322.It Cm p 323.It Cm p
323.Dq User 324.Dq User
324bits from the string form of permissions or the file 325bits from the string form of permissions or the file
325.Dq type 326.Dq type
326bits from the numeric forms 327bits from the numeric forms
327.It Cm T 328.It Cm T
328The long output form of file type 329The long output form of file type
329.It Cm N 330.It Cm N
330Directory path of the file, similar to what 331Directory path of the file, similar to what
331.Xr dirname 1 332.Xr dirname 1
332would show 333would show
333.It Cm z 334.It Cm z
334File size, rounded to the nearest gigabyte 335File size, rounded to the nearest gigabyte
335.El 336.El
336.It Cm M 337.It Cm M
337.Dq Middle 338.Dq Middle
338-- depending on the 339-- depending on the
339.Cm datum : 340.Cm datum :
340.Bl -tag -compact -width door 341.Bl -tag -compact -width door
341.It Cm p 342.It Cm p
342The 343The
343.Dq group 344.Dq group
344bits from the string form of permissions or the 345bits from the string form of permissions or the
345.Dq suid , 346.Dq suid ,
346.Dq sgid , 347.Dq sgid ,
347and 348and
348.Dq sticky 349.Dq sticky
349bits from the numeric forms 350bits from the numeric forms
350.It Cm z 351.It Cm z
351File size, rounded to the nearest megabyte 352File size, rounded to the nearest megabyte
352.El 353.El
353.It Cm L 354.It Cm L
354.Dq Low 355.Dq Low
355-- depending on the 356-- depending on the
356.Cm datum : 357.Cm datum :
357.Bl -tag -compact -width door 358.Bl -tag -compact -width door
358.It Cm r , d 359.It Cm r , d
359Minor number for devices 360Minor number for devices
360.It Cm p 361.It Cm p
361The 362The
362.Dq other 363.Dq other
363bits from the string form of permissions or the 364bits from the string form of permissions or the
364.Dq user , 365.Dq user ,
365.Dq group , 366.Dq group ,
366and 367and
367.Dq other 368.Dq other
368bits from the numeric forms 369bits from the numeric forms
369.It Cm T 370.It Cm T
370The 371The
371.Ic ls -F 372.Ic ls -F
372style output character for file type (the use of 373style output character for file type (the use of
373.Cm L 374.Cm L
374here is optional) 375here is optional)
375.It Cm N 376.It Cm N
376Base filename of the file, similar to what 377Base filename of the file, similar to what
377.Xr basename 1 378.Xr basename 1
378would show 379would show
379.It Cm z 380.It Cm z
380File size, rounded to the nearest kilobyte 381File size, rounded to the nearest kilobyte
381.El 382.El
382.El 383.El
383.It Cm datum 384.It Cm datum
384A required field specifier, being one of the following: 385A required field specifier, being one of the following:
385.Bl -tag -width 11n 386.Bl -tag -width 11n
386.It Cm d 387.It Cm d
387Device upon which 388Device upon which
388.Ar file 389.Ar file
389resides 390resides
390.Pq Fa st_dev . 391.Pq Fa st_dev .
391.It Cm i 392.It Cm i
392.Ar file Ap s 393.Ar file Ap s
393inode number 394inode number
394.Pq Fa st_ino . 395.Pq Fa st_ino .
395.It Cm p 396.It Cm p
396File type and permissions 397File type and permissions
397.Pq Fa st_mode . 398.Pq Fa st_mode .
398.It Cm l 399.It Cm l
399Number of hard links to 400Number of hard links to
400.Ar file 401.Ar file
401.Pq Fa st_nlink . 402.Pq Fa st_nlink .
402.It Cm u , g 403.It Cm u , g
403User-id and group-id of 404User-id and group-id of
404.Ar file Ap s 405.Ar file Ap s
405owner 406owner
406.Pq Fa st_uid , st_gid . 407.Pq Fa st_uid , st_gid .
407.It Cm r 408.It Cm r
408Device number for character and block device special files 409Device number for character and block device special files
409.Pq Fa st_rdev . 410.Pq Fa st_rdev .
410.It Cm a , m , c , B 411.It Cm a , m , c , B
411The time 412The time
412.Ar file 413.Ar file
413was last accessed or modified, or when the inode was last changed, or 414was last accessed or modified, or when the inode was last changed, or
414the birth time of the inode 415the birth time of the inode
415.Pq Fa st_atime , st_mtime , st_ctime, st_birthtime . 416.Pq Fa st_atime , st_mtime , st_ctime , st_birthtime .
416.It Cm z 417.It Cm z
417The size of 418The size of
418.Ar file 419.Ar file
419in bytes 420in bytes
420.Pq Fa st_size . 421.Pq Fa st_size .
421.It Cm b 422.It Cm b
422Number of blocks allocated for 423Number of blocks allocated for
423.Ar file 424.Ar file
424.Pq Fa st_blocks . 425.Pq Fa st_blocks .
425.It Cm k 426.It Cm k
426Optimal file system I/O operation block size 427Optimal file system I/O operation block size
427.Pq Fa st_blksize . 428.Pq Fa st_blksize .
428.It Cm f 429.It Cm f
429User defined flags for 430User defined flags for
430.Ar file 431.Ar file
431.Pq Fa st_flags . 432.Pq Fa st_flags .
432.It Cm v 433.It Cm v
433Inode generation number 434Inode generation number
434.Pq Fa st_gen . 435.Pq Fa st_gen .
435.El 436.El
436.Pp 437.Pp
437The following five field specifiers are not drawn directly from the 438The following five field specifiers are not drawn directly from the
438data in struct stat, but are: 439data in struct stat, but are:
439.Bl -tag -width Ds 440.Bl -tag -width Ds
440.It Cm N 441.It Cm N
441The name of the file. 442The name of the file.
442.It Cm R 443.It Cm R
443The absolute pathname corresponding to the file. 444The absolute pathname corresponding to the file.
444.It Cm T 445.It Cm T
445The file type, either as in 446The file type, either as in
446.Ic ls -F 447.Ic ls -F
447or in a more descriptive form if the sub field specifier 448or in a more descriptive form if the sub field specifier
448.Cm H 449.Cm H
449is given. 450is given.
450.It Cm Y 451.It Cm Y
451The target of a symbolic link. 452The target of a symbolic link.
452.It Cm Z 453.It Cm Z
453Expands to 454Expands to
454.Dq Ar major , Ns Ar minor 455.Dq Ar major , Ns Ar minor
455from the rdev field for character or block 456from the rdev field for character or block
456special devices and gives size output for all others. 457special devices and gives size output for all others.
457.El 458.El
458.El 459.El
459.Pp 460.Pp
460Only the 461Only the
461.Cm % 462.Cm %
462and the field specifier are required. 463and the field specifier are required.
463Most field specifiers default to 464Most field specifiers default to
464.Cm U 465.Cm U
465as an output form, with the 466as an output form, with the
466exception of 467exception of
467.Cm p 468.Cm p
468which defaults to 469which defaults to
469.Cm O ; 470.Cm O ;
470.Cm a , m , 471.Cm a , m ,
471and 472and
472.Cm c 473.Cm c
473which default to 474which default to
474.Cm D ; 475.Cm D ;
475and 476and
476.Cm Y , T , 477.Cm Y , T ,
477and 478and
478.Cm N , 479.Cm N ,
479which default to 480which default to
480.Cm S . 481.Cm S .
481.Sh EXIT STATUS 482.Sh EXIT STATUS
482.Ex -std 483.Ex -std
483.Sh EXAMPLES 484.Sh EXAMPLES
484If no options are specified, the default format is 485If no options are specified, the default format is
485"%d %i %Sp %l %Su %Sg %r %z \e"%Sa\e" \e"%Sm\e" \e"%Sc\e" \e"%SB\e" %k %b %#Xf %N". 486"%d %i %Sp %l %Su %Sg %r %z \e"%Sa\e" \e"%Sm\e" \e"%Sc\e" \e"%SB\e" %k %b %#Xf %N".
486.Bd -literal -offset indent 487.Bd -literal -offset indent
487> stat /tmp/bar 488> stat /tmp/bar
4880 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 4890 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
489.Ed 490.Ed
490.Pp 491.Pp
491This example produces output very similar to that from 492This example produces output very similar to that from
492.Ic find ... -ls 493.Ic find ... -ls
493(except that 494(except that
494.Xr find 1 495.Xr find 1
495displays the time in a different format, and 496displays the time in a different format, and
496.Xr find 1 497.Xr find 1
497sometimes adds one or more spaces after the comma in 498sometimes adds one or more spaces after the comma in
498.Dq Ar major , Ns Ar minor 499.Dq Ar major , Ns Ar minor
499for device nodes): 500for device nodes):
500.Bd -literal -offset indent 501.Bd -literal -offset indent
501> stat -f "%7i %6b %-11Sp %3l %-17Su %-17Sg %9Z %Sm %N%SY" /tmp/bar 502> stat -f "%7i %6b %-11Sp %3l %-17Su %-17Sg %9Z %Sm %N%SY" /tmp/bar
502 78852 0 -rw-r--r-- 1 root wheel 0 Jul 8 10:26:03 2004 /tmp/bar 503 78852 0 -rw-r--r-- 1 root wheel 0 Jul 8 10:26:03 2004 /tmp/bar
503 504
504> find /tmp/bar -ls -exit 505> find /tmp/bar -ls -exit
505 78852 0 -rw-r--r-- 1 root wheel 0 Jul 8 2004 /tmp/bar 506 78852 0 -rw-r--r-- 1 root wheel 0 Jul 8 2004 /tmp/bar
506.Ed 507.Ed
507.Pp 508.Pp
508This example produces output very similar to that from 509This example produces output very similar to that from
509.Ic ls -lTd 510.Ic ls -lTd
510(except that 511(except that
511.Xr ls 1 512.Xr ls 1
512adjusts the column spacing differently when listing multiple files, 513adjusts the column spacing differently when listing multiple files,
513and 514and
514.Xr ls 1 515.Xr ls 1
515adds at least one space after the comma in 516adds at least one space after the comma in
516.Dq Ar major , Ns Ar minor 517.Dq Ar major , Ns Ar minor
517for device nodes): 518for device nodes):
518.Bd -literal -offset indent 519.Bd -literal -offset indent
519> stat -f "%-11Sp %l %Su %Sg %Z %Sm %N%SY" /tmp/bar 520> stat -f "%-11Sp %l %Su %Sg %Z %Sm %N%SY" /tmp/bar
520-rw-r--r-- 1 root wheel 0 Jul 8 10:26:03 2004 /tmp/bar 521-rw-r--r-- 1 root wheel 0 Jul 8 10:26:03 2004 /tmp/bar
521 522
522> ls -lTd /tmp/bar 523> ls -lTd /tmp/bar
523-rw-r--r-- 1 root wheel 0 Jul 8 10:26:03 2004 /tmp/bar 524-rw-r--r-- 1 root wheel 0 Jul 8 10:26:03 2004 /tmp/bar
524.Ed 525.Ed
525.Pp 526.Pp
526Given a symbolic link 527Given a symbolic link
527.Dq foo 528.Dq foo
528that points from 529that points from
529.Pa /tmp/foo 530.Pa /tmp/foo
530to 531to
531.Pa / , 532.Pa / ,
532you would use 533you would use
533.Nm 534.Nm
534as follows: 535as follows:
535.Bd -literal -offset indent 536.Bd -literal -offset indent
536> stat -F /tmp/foo 537> stat -F /tmp/foo
537lrwxrwxrwx 1 jschauma cs 1 Apr 24 16:37:28 2002 /tmp/foo@ -> / 538lrwxrwxrwx 1 jschauma cs 1 Apr 24 16:37:28 2002 /tmp/foo@ -> /
538 539
539> stat -LF /tmp/foo 540> stat -LF /tmp/foo
540drwxr-xr-x 16 root wheel 512 Apr 19 10:57:54 2002 /tmp/foo/ 541drwxr-xr-x 16 root wheel 512 Apr 19 10:57:54 2002 /tmp/foo/
541.Ed 542.Ed
542.Pp 543.Pp
543To initialize some shell-variables, you could use the 544To initialize some shell-variables, you could use the
544.Fl s 545.Fl s
545flag as follows: 546flag as follows:
546.Bd -literal -offset indent 547.Bd -literal -offset indent
547> csh 548> csh
548% eval set `stat -s .cshrc` 549% eval set `stat -s .cshrc`
549% echo $st_size $st_mtime 550% echo $st_size $st_mtime
5501148 1015432481 5511148 1015432481
551 552
552> sh 553> sh
553$ eval $(stat -s .profile) 554$ eval $(stat -s .profile)
554$ echo $st_size $st_mtime 555$ echo $st_size $st_mtime
5551148 1015432481 5561148 1015432481
556.Ed 557.Ed
557.Pp 558.Pp
558In order to get a list of the kind of files including files pointed to if the 559In order to get a list of the kind of files including files pointed to if the
559file is a symbolic link, you could use the following format: 560file is a symbolic link, you could use the following format:
560.Bd -literal -offset indent 561.Bd -literal -offset indent
561$ stat -f "%N: %HT%SY" /tmp/* 562$ stat -f "%N: %HT%SY" /tmp/*
562/tmp/bar: Symbolic Link -> /tmp/foo 563/tmp/bar: Symbolic Link -> /tmp/foo
563/tmp/output25568: Regular File 564/tmp/output25568: Regular File
564/tmp/blah: Directory 565/tmp/blah: Directory
565/tmp/foo: Symbolic Link -> / 566/tmp/foo: Symbolic Link -> /
566.Ed 567.Ed
567.Pp 568.Pp
568In order to get a list of the devices, their types and the major and minor 569In order to get a list of the devices, their types and the major and minor
569device numbers, formatted with tabs and linebreaks, you could use the 570device numbers, formatted with tabs and linebreaks, you could use the
570following format: 571following format:
571.Bd -literal -offset indent 572.Bd -literal -offset indent
572stat -f "Name: %N%n%tType: %HT%n%tMajor: %Hr%n%tMinor: %Lr%n%n" /dev/* 573stat -f "Name: %N%n%tType: %HT%n%tMajor: %Hr%n%tMinor: %Lr%n%n" /dev/*
573[...] 574[...]
574Name: /dev/wt8 575Name: /dev/wt8
575 Type: Block Device 576 Type: Block Device
576 Major: 3 577 Major: 3
577 Minor: 8 578 Minor: 8
578 579
579Name: /dev/zero 580Name: /dev/zero
580 Type: Character Device 581 Type: Character Device
581 Major: 2 582 Major: 2
582 Minor: 12 583 Minor: 12
583.Ed 584.Ed
584.Pp 585.Pp
585In order to determine the permissions set on a file separately, you could use 586In order to determine the permissions set on a file separately, you could use
586the following format: 587the following format:
587.Bd -literal -offset indent 588.Bd -literal -offset indent
588> stat -f "%Sp -> owner=%SHp group=%SMp other=%SLp" . 589> stat -f "%Sp -> owner=%SHp group=%SMp other=%SLp" .
589drwxr-xr-x -> owner=rwx group=r-x other=r-x 590drwxr-xr-x -> owner=rwx group=r-x other=r-x
590.Ed 591.Ed
591.Pp 592.Pp
592In order to determine the three files that have been modified most recently, 593In order to determine the three files that have been modified most recently,
593you could use the following format: 594you could use the following format:
594.Bd -literal -offset indent 595.Bd -literal -offset indent
595> stat -f "%m%t%Sm %N" /tmp/* | sort -rn | head -3 | cut -f2- 596> stat -f "%m%t%Sm %N" /tmp/* | sort -rn | head -3 | cut -f2-
596Apr 25 11:47:00 2002 /tmp/blah 597Apr 25 11:47:00 2002 /tmp/blah
597Apr 25 10:36:34 2002 /tmp/bar 598Apr 25 10:36:34 2002 /tmp/bar
598Apr 24 16:47:35 2002 /tmp/foo 599Apr 24 16:47:35 2002 /tmp/foo
599.Ed 600.Ed
600.Pp 601.Pp
601User names, group names, and file names that contain spaces 602User names, group names, and file names that contain spaces
602or other special characters may be encoded in 603or other special characters may be encoded in
603.Xr vis 3 604.Xr vis 3
604style, using the 605style, using the
605.Cm \&# 606.Cm \&#
606modifier: 607modifier:
607.Bd -literal -offset indent 608.Bd -literal -offset indent
608> ln -s 'target with spaces' 'link with spaces' 609> ln -s 'target with spaces' 'link with spaces'
609> stat -f "%#N%#SY" 'link with spaces' 610> stat -f "%#N%#SY" 'link with spaces'
610link\eswith\esspaces -> target\eswith\esspaces 611link\eswith\esspaces -> target\eswith\esspaces
611.Ed 612.Ed
612.Sh SEE ALSO 613.Sh SEE ALSO
613.Xr basename 1 , 614.Xr basename 1 ,
614.Xr dirname 1 , 615.Xr dirname 1 ,
615.Xr file 1 , 616.Xr file 1 ,
616.Xr ls 1 , 617.Xr ls 1 ,
617.Xr lstat 2 , 618.Xr lstat 2 ,
618.Xr readlink 2 , 619.Xr readlink 2 ,
619.Xr stat 2 , 620.Xr stat 2 ,
620.Xr printf 3 , 621.Xr printf 3 ,
621.Xr strftime 3 622.Xr strftime 3
622.Sh HISTORY 623.Sh HISTORY
623The 624The
624.Nm 625.Nm
625utility appeared in 626utility appeared in
626.Nx 1.6 . 627.Nx 1.6 .
627.Sh AUTHORS 628.Sh AUTHORS
628.An -nosplit 629.An -nosplit
629The 630The
630.Nm 631.Nm
631utility was written by 632utility was written by
632.An Andrew Brown 633.An Andrew Brown
633.Aq atatat@NetBSD.org . 634.Aq atatat@NetBSD.org .
634This man page was written by 635This man page was written by
635.An Jan Schaumann 636.An Jan Schaumann
636.Aq jschauma@NetBSD.org . 637.Aq jschauma@NetBSD.org .