| @@ -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 |
53 | The | | 53 | The |
54 | .Nm | | 54 | .Nm |
55 | utility displays information about the file pointed to by | | 55 | utility displays information about the file pointed to by |
56 | .Ar file . | | 56 | .Ar file . |
57 | Read, write, or execute permissions of the named file are not required, but | | 57 | Read, write, or execute permissions of the named file are not required, but |
58 | all directories listed in the pathname leading to the file must be | | 58 | all directories listed in the pathname leading to the file must be |
59 | searchable. | | 59 | searchable. |
60 | If no argument is given, | | 60 | If no argument is given, |
61 | .Nm | | 61 | .Nm |
62 | displays information about the file descriptor for standard input. | | 62 | displays information about the file descriptor for standard input. |
63 | .Pp | | 63 | .Pp |
64 | When invoked as | | 64 | When invoked as |
65 | .Nm readlink , | | 65 | .Nm readlink , |
66 | only the target of the symbolic link is printed. | | 66 | only the target of the symbolic link is printed. |
67 | If the given argument is not a symbolic link and the | | 67 | If the given argument is not a symbolic link and the |
68 | .Fl f | | 68 | .Fl f |
69 | option is not specified, | | 69 | option is not specified, |
70 | .Nm readlink | | 70 | .Nm readlink |
71 | will print nothing and exit with an error. | | 71 | will print nothing and exit with an error. |
72 | If the | | 72 | If the |
73 | .Fl f | | 73 | .Fl f |
74 | option is specified, the output is canonicalized by following every symlink | | 74 | option is specified, the output is canonicalized by following every symlink |
75 | in every component of the given path recursively. | | 75 | in every component of the given path recursively. |
76 | .Nm readlink | | 76 | .Nm readlink |
77 | will resolve both absolute and relative paths, and return the absolute pathname | | 77 | will resolve both absolute and relative paths, and return the absolute pathname |
78 | corresponding to | | 78 | corresponding to |
79 | .Ar file . | | 79 | .Ar file . |
80 | In this case, the argument does not need to be a symbolic link. | | 80 | In this case, the argument does not need to be a symbolic link. |
81 | .Pp | | 81 | .Pp |
82 | The information displayed is obtained by calling | | 82 | The information displayed is obtained by calling |
83 | .Xr lstat 2 | | 83 | .Xr lstat 2 |
84 | with the given argument and evaluating the returned structure. | | 84 | with the given argument and evaluating the returned structure. |
85 | The default format displays the | | 85 | The 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 , |
100 | and | | 100 | and |
101 | .Fa st_flags | | 101 | .Fa st_flags |
102 | fields, in that order. | | 102 | fields, in that order. |
103 | .Pp | | 103 | .Pp |
104 | The options are as follows: | | 104 | The options are as follows: |
105 | .Bl -tag -width XFXformatXXX | | 105 | .Bl -tag -width XFXformatXXX |
106 | .It Fl F | | 106 | .It Fl F |
107 | As in | | 107 | As in |
108 | .Xr ls 1 , | | 108 | .Xr ls 1 , |
109 | display a slash | | 109 | display a slash |
110 | .Pq Sq / | | 110 | .Pq Sq / |
111 | immediately after each pathname that is a directory, an | | 111 | immediately after each pathname that is a directory, an |
112 | asterisk | | 112 | asterisk |
113 | .Pq Sq * | | 113 | .Pq Sq * |
114 | after each that is executable, an at sign | | 114 | after each that is executable, an at sign |
115 | .Pq Sq @ | | 115 | .Pq Sq @ |
116 | after each symbolic link, a percent sign | | 116 | after each symbolic link, a percent sign |
117 | .Pq Sq % | | 117 | .Pq Sq % |
118 | after each whiteout, an equal sign | | 118 | after each whiteout, an equal sign |
119 | .Pq Sq = | | 119 | .Pq Sq = |
120 | after each socket, and a vertical bar | | 120 | after each socket, and a vertical bar |
121 | .Pq Sq \&| | | 121 | .Pq Sq \&| |
122 | after each that is a FIFO. | | 122 | after each that is a FIFO. |
123 | The use of | | 123 | The use of |
124 | .Fl F | | 124 | .Fl F |
125 | implies | | 125 | implies |
126 | .Fl l . | | 126 | .Fl l . |
127 | .It Fl f Ar format | | 127 | .It Fl f Ar format |
128 | Display information using the specified format. | | 128 | Display information using the specified format. |
129 | See the | | 129 | See the |
130 | .Sx FORMATS | | 130 | .Sx FORMATS |
131 | section for a description of valid formats. | | 131 | section for a description of valid formats. |
132 | .It Fl L | | 132 | .It Fl L |
133 | Use | | 133 | Use |
134 | .Xr stat 2 | | 134 | .Xr stat 2 |
135 | instead of | | 135 | instead of |
136 | .Xr lstat 2 . | | 136 | .Xr lstat 2 . |
137 | The information reported by | | 137 | The information reported by |
138 | .Nm | | 138 | .Nm |
139 | will refer to the target of | | 139 | will refer to the target of |
140 | .Ar file , | | 140 | .Ar file , |
141 | if file is a symbolic link, and not to | | 141 | if file is a symbolic link, and not to |
142 | .Ar file | | 142 | .Ar file |
143 | itself. | | 143 | itself. |
144 | .It Fl l | | 144 | .It Fl l |
145 | Display output in | | 145 | Display output in |
146 | .Ic ls Fl lT | | 146 | .Ic ls Fl lT |
147 | format. | | 147 | format. |
148 | .It Fl n | | 148 | .It Fl n |
149 | Do not force a newline to appear at the end of each piece of output. | | 149 | Do not force a newline to appear at the end of each piece of output. |
150 | .It Fl q | | 150 | .It Fl q |
151 | Suppress failure messages if calls to | | 151 | Suppress failure messages if calls to |
152 | .Xr stat 2 | | 152 | .Xr stat 2 |
153 | or | | 153 | or |
154 | .Xr lstat 2 | | 154 | .Xr lstat 2 |
155 | fail. | | 155 | fail. |
156 | When run as | | 156 | When run as |
157 | .Nm readlink , | | 157 | .Nm readlink , |
158 | error messages are automatically suppressed. | | 158 | error messages are automatically suppressed. |
159 | .It Fl r | | 159 | .It Fl r |
160 | Display raw information. | | 160 | Display raw information. |
161 | That is, for all the fields in the stat-structure, | | 161 | That is, for all the fields in the stat-structure, |
162 | display the raw, numerical value (for example, times in seconds since the | | 162 | display the raw, numerical value (for example, times in seconds since the |
163 | epoch, etc.) | | 163 | epoch, etc.) |
164 | .It Fl s | | 164 | .It Fl s |
165 | Display information in | | 165 | Display information in |
166 | .Dq shell output , | | 166 | .Dq shell output , |
167 | suitable for initializing variables. | | 167 | suitable for initializing variables. |
168 | When run as | | 168 | When run as |
169 | .Nm readlink , | | 169 | .Nm readlink , |
170 | suppress error messages. | | 170 | suppress error messages. |
171 | This is equivalent to specifying | | 171 | This is equivalent to specifying |
172 | .Bd -literal | | 172 | .Bd -literal |
173 | FMT="st_dev=%d st_ino=%i st_mode=%#p st_nlink=%l st_uid=%u st_gid=%g" | | 173 | FMT="st_dev=%d st_ino=%i st_mode=%#p st_nlink=%l st_uid=%u st_gid=%g" |
174 | FMT="$FMT st_rdev=%r st_size=%z st_atime=%Sa st_mtime=%Sm st_ctime=%Sc" | | 174 | FMT="$FMT st_rdev=%r st_size=%z st_atime=%Sa st_mtime=%Sm st_ctime=%Sc" |
175 | FMT="$FMT st_birthtime=%SB st_blksize=%k st_blocks=%b st_flags=%f" | | 175 | FMT="$FMT st_birthtime=%SB st_blksize=%k st_blocks=%b st_flags=%f" |
176 | stat -t %s -f "$FMT" . | | 176 | stat -t %s -f "$FMT" . |
177 | .Ed | | 177 | .Ed |
178 | Note that if you use a timeformat that contains embedded whitespace or shell | | 178 | Note that if you use a timeformat that contains embedded whitespace or shell |
179 | meta-characters you will need to include appropriate quoting so the | | 179 | meta-characters you will need to include appropriate quoting so the |
180 | .Fl s | | 180 | .Fl s |
181 | output remains valid. | | 181 | output remains valid. |
182 | .It Fl t Ar timefmt | | 182 | .It Fl t Ar timefmt |
183 | Display timestamps using the specified format. | | 183 | Display timestamps using the specified format. |
184 | This format is | | 184 | This format is |
185 | passed directly to | | 185 | passed directly to |
186 | .Xr strftime 3 | | 186 | .Xr strftime 3 |
187 | with the extension that %f prints nanoseconds if available. | | 187 | with the extension that %f prints nanoseconds if available. |
188 | .It Fl v | | 188 | .It Fl v |
189 | Turn off quiet mode. | | 189 | Turn off quiet mode. |
190 | .It Fl x | | 190 | .It Fl x |
191 | Display information in a more verbose way as known from some Linux | | 191 | Display information in a more verbose way as known from some Linux |
192 | distributions. | | 192 | distributions. |
193 | .El | | 193 | .El |
194 | .Ss FORMATS | | 194 | .Ss FORMATS |
195 | Format strings are similar to | | 195 | Format strings are similar to |
196 | .Xr printf 3 | | 196 | .Xr printf 3 |
197 | formats in that they start with | | 197 | formats in that they start with |
198 | .Cm % , | | 198 | .Cm % , |
199 | are then followed by a sequence of formatting characters, and end in | | 199 | are then followed by a sequence of formatting characters, and end in |
200 | a character that selects the field of the struct stat which is to be | | 200 | a character that selects the field of the struct stat which is to be |
201 | formatted. | | 201 | formatted. |
202 | If the | | 202 | If the |
203 | .Cm % | | 203 | .Cm % |
204 | is immediately followed by one of | | 204 | is immediately followed by one of |
205 | .Cm n , | | 205 | .Cm n , |
206 | .Cm t , | | 206 | .Cm t , |
207 | .Cm % , | | 207 | .Cm % , |
208 | or | | 208 | or |
209 | .Cm @ , | | 209 | .Cm @ , |
210 | then a newline character, a tab character, a percent character, | | 210 | then a newline character, a tab character, a percent character, |
211 | or the current file number is printed, otherwise the string is | | 211 | or the current file number is printed, otherwise the string is |
212 | examined for the following: | | 212 | examined for the following: |
213 | .Pp | | 213 | .Pp |
214 | Any of the following optional flags: | | 214 | Any of the following optional flags: |
215 | .Bl -tag -width Ds | | 215 | .Bl -tag -width Ds |
216 | .It Cm # | | 216 | .It Cm # |
217 | Selects an alternate output form for string, octal and hexadecimal output. | | 217 | Selects an alternate output form for string, octal and hexadecimal output. |
218 | String output will be encoded in | | 218 | String output will be encoded in |
219 | .Xr vis 3 | | 219 | .Xr vis 3 |
220 | style. | | 220 | style. |
221 | Non-zero octal output will have a leading zero. | | 221 | Non-zero octal output will have a leading zero. |
222 | Non-zero hexadecimal output will have | | 222 | Non-zero hexadecimal output will have |
223 | .Dq 0x | | 223 | .Dq 0x |
224 | prepended to it. | | 224 | prepended to it. |
225 | .It Cm + | | 225 | .It Cm + |
226 | Asserts that a sign indicating whether a number is positive or negative | | 226 | Asserts that a sign indicating whether a number is positive or negative |
227 | should always be printed. | | 227 | should always be printed. |
228 | Non-negative numbers are not usually printed with a sign. | | 228 | Non-negative numbers are not usually printed with a sign. |
229 | .It Cm - | | 229 | .It Cm - |
230 | Aligns string output to the left of the field, instead of to the right. | | 230 | Aligns string output to the left of the field, instead of to the right. |
231 | .It Cm 0 | | 231 | .It Cm 0 |
232 | Sets the fill character for left padding to the 0 character, instead of | | 232 | Sets the fill character for left padding to the 0 character, instead of |
233 | a space. | | 233 | a space. |
234 | .It space | | 234 | .It space |
235 | Reserves a space at the front of non-negative signed output fields. | | 235 | Reserves a space at the front of non-negative signed output fields. |
236 | A | | 236 | A |
237 | .Sq Cm + | | 237 | .Sq Cm + |
238 | overrides a space if both are used. | | 238 | overrides a space if both are used. |
239 | .El | | 239 | .El |
240 | .Pp | | 240 | .Pp |
241 | Then the following fields: | | 241 | Then the following fields: |
242 | .Bl -tag -width Ds | | 242 | .Bl -tag -width Ds |
243 | .It Cm size | | 243 | .It Cm size |
244 | An optional decimal digit string specifying the minimum field width. | | 244 | An optional decimal digit string specifying the minimum field width. |
245 | .It Cm prec | | 245 | .It Cm prec |
246 | An optional precision composed of a decimal point | | 246 | An optional precision composed of a decimal point |
247 | .Sq Cm \&. | | 247 | .Sq Cm \&. |
248 | and a decimal digit string that indicates the maximum string length, | | 248 | and a decimal digit string that indicates the maximum string length, |
249 | the number of digits to appear after the decimal point in floating point | | 249 | the number of digits to appear after the decimal point in floating point |
250 | output, or the minimum number of digits to appear in numeric output. | | 250 | output, or the minimum number of digits to appear in numeric output. |
251 | .It Cm fmt | | 251 | .It Cm fmt |
252 | An optional output format specifier which is one of | | 252 | An 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 , |
258 | or | | 258 | or |
259 | .Cm S . | | 259 | .Cm S . |
260 | These represent signed decimal output, octal output, unsigned decimal | | 260 | These represent signed decimal output, octal output, unsigned decimal |
261 | output, hexadecimal output, floating point output, and string output, | | 261 | output, hexadecimal output, floating point output, and string output, |
262 | respectively. | | 262 | respectively. |
263 | Some output formats do not apply to all fields. | | 263 | Some output formats do not apply to all fields. |
264 | Floating point output only applies to timespec fields (the | | 264 | Floating point output only applies to timespec fields (the |
265 | .Cm a , | | 265 | .Cm a , |
266 | .Cm m , | | 266 | .Cm m , |
267 | and | | 267 | and |
268 | .Cm c | | 268 | .Cm c |
269 | fields). | | 269 | fields). |
270 | .Pp | | 270 | .Pp |
271 | The special output specifier | | 271 | The special output specifier |
272 | .Cm S | | 272 | .Cm S |
273 | may be used to indicate that the output, if | | 273 | may be used to indicate that the output, if |
274 | applicable, should be in string format. | | 274 | applicable, should be in string format. |
275 | May be used in combination with | | 275 | May be used in combination with |
276 | .Bl -tag -width Ds | | 276 | .Bl -tag -width Ds |
277 | .It Cm amc | | 277 | .It Cm amc |
278 | Display date in strftime(3) format | | 278 | Display date in |
279 | with the extension that %f prints nanoseconds if available. | | 279 | .Xr strftime 3 |
| | | 280 | format with the extension that %f prints nanoseconds if available. |
280 | .It Cm dr | | 281 | .It Cm dr |
281 | Display actual device name. | | 282 | Display actual device name. |
282 | .It Cm gu | | 283 | .It Cm gu |
283 | Display group or user name. | | 284 | Display group or user name. |
284 | .It Cm p | | 285 | .It Cm p |
285 | Display the mode of | | 286 | Display the mode of |
286 | .Ar file | | 287 | .Ar file |
287 | as in | | 288 | as in |
288 | .Ic ls -lTd . | | 289 | .Ic ls -lTd . |
289 | .It Cm N | | 290 | .It Cm N |
290 | Displays the name of | | 291 | Displays the name of |
291 | .Ar file . | | 292 | .Ar file . |
292 | .It Cm T | | 293 | .It Cm T |
293 | Displays the type of | | 294 | Displays the type of |
294 | .Ar file . | | 295 | .Ar file . |
295 | .It Cm Y | | 296 | .It Cm Y |
296 | Insert a `` -> '' into the output. | | 297 | Insert a `` -> '' into the output. |
297 | Note that the default output format for | | 298 | Note that the default output format for |
298 | .Cm Y | | 299 | .Cm Y |
299 | is a string, but if specified explicitly, these four characters are | | 300 | is a string, but if specified explicitly, these four characters are |
300 | prepended. | | 301 | prepended. |
301 | .El | | 302 | .El |
302 | .It Cm sub | | 303 | .It Cm sub |
303 | An optional sub field specifier (high, middle, or low). | | 304 | An optional sub field specifier (high, middle, or low). |
304 | Only applies to the | | 305 | Only 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 , |
310 | and | | 311 | and |
311 | .Cm z | | 312 | .Cm z |
312 | output formats. | | 313 | output formats. |
313 | It can be one of the following: | | 314 | It 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 |
321 | Major number for devices | | 322 | Major number for devices |
322 | .It Cm p | | 323 | .It Cm p |
323 | .Dq User | | 324 | .Dq User |
324 | bits from the string form of permissions or the file | | 325 | bits from the string form of permissions or the file |
325 | .Dq type | | 326 | .Dq type |
326 | bits from the numeric forms | | 327 | bits from the numeric forms |
327 | .It Cm T | | 328 | .It Cm T |
328 | The long output form of file type | | 329 | The long output form of file type |
329 | .It Cm N | | 330 | .It Cm N |
330 | Directory path of the file, similar to what | | 331 | Directory path of the file, similar to what |
331 | .Xr dirname 1 | | 332 | .Xr dirname 1 |
332 | would show | | 333 | would show |
333 | .It Cm z | | 334 | .It Cm z |
334 | File size, rounded to the nearest gigabyte | | 335 | File 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 |
342 | The | | 343 | The |
343 | .Dq group | | 344 | .Dq group |
344 | bits from the string form of permissions or the | | 345 | bits from the string form of permissions or the |
345 | .Dq suid , | | 346 | .Dq suid , |
346 | .Dq sgid , | | 347 | .Dq sgid , |
347 | and | | 348 | and |
348 | .Dq sticky | | 349 | .Dq sticky |
349 | bits from the numeric forms | | 350 | bits from the numeric forms |
350 | .It Cm z | | 351 | .It Cm z |
351 | File size, rounded to the nearest megabyte | | 352 | File 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 |
359 | Minor number for devices | | 360 | Minor number for devices |
360 | .It Cm p | | 361 | .It Cm p |
361 | The | | 362 | The |
362 | .Dq other | | 363 | .Dq other |
363 | bits from the string form of permissions or the | | 364 | bits from the string form of permissions or the |
364 | .Dq user , | | 365 | .Dq user , |
365 | .Dq group , | | 366 | .Dq group , |
366 | and | | 367 | and |
367 | .Dq other | | 368 | .Dq other |
368 | bits from the numeric forms | | 369 | bits from the numeric forms |
369 | .It Cm T | | 370 | .It Cm T |
370 | The | | 371 | The |
371 | .Ic ls -F | | 372 | .Ic ls -F |
372 | style output character for file type (the use of | | 373 | style output character for file type (the use of |
373 | .Cm L | | 374 | .Cm L |
374 | here is optional) | | 375 | here is optional) |
375 | .It Cm N | | 376 | .It Cm N |
376 | Base filename of the file, similar to what | | 377 | Base filename of the file, similar to what |
377 | .Xr basename 1 | | 378 | .Xr basename 1 |
378 | would show | | 379 | would show |
379 | .It Cm z | | 380 | .It Cm z |
380 | File size, rounded to the nearest kilobyte | | 381 | File size, rounded to the nearest kilobyte |
381 | .El | | 382 | .El |
382 | .El | | 383 | .El |
383 | .It Cm datum | | 384 | .It Cm datum |
384 | A required field specifier, being one of the following: | | 385 | A 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 |
387 | Device upon which | | 388 | Device upon which |
388 | .Ar file | | 389 | .Ar file |
389 | resides | | 390 | resides |
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 |
393 | inode number | | 394 | inode number |
394 | .Pq Fa st_ino . | | 395 | .Pq Fa st_ino . |
395 | .It Cm p | | 396 | .It Cm p |
396 | File type and permissions | | 397 | File type and permissions |
397 | .Pq Fa st_mode . | | 398 | .Pq Fa st_mode . |
398 | .It Cm l | | 399 | .It Cm l |
399 | Number of hard links to | | 400 | Number 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 |
403 | User-id and group-id of | | 404 | User-id and group-id of |
404 | .Ar file Ap s | | 405 | .Ar file Ap s |
405 | owner | | 406 | owner |
406 | .Pq Fa st_uid , st_gid . | | 407 | .Pq Fa st_uid , st_gid . |
407 | .It Cm r | | 408 | .It Cm r |
408 | Device number for character and block device special files | | 409 | Device 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 |
411 | The time | | 412 | The time |
412 | .Ar file | | 413 | .Ar file |
413 | was last accessed or modified, or when the inode was last changed, or | | 414 | was last accessed or modified, or when the inode was last changed, or |
414 | the birth time of the inode | | 415 | the 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 |
417 | The size of | | 418 | The size of |
418 | .Ar file | | 419 | .Ar file |
419 | in bytes | | 420 | in bytes |
420 | .Pq Fa st_size . | | 421 | .Pq Fa st_size . |
421 | .It Cm b | | 422 | .It Cm b |
422 | Number of blocks allocated for | | 423 | Number 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 |
426 | Optimal file system I/O operation block size | | 427 | Optimal 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 |
429 | User defined flags for | | 430 | User 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 |
433 | Inode generation number | | 434 | Inode generation number |
434 | .Pq Fa st_gen . | | 435 | .Pq Fa st_gen . |
435 | .El | | 436 | .El |
436 | .Pp | | 437 | .Pp |
437 | The following five field specifiers are not drawn directly from the | | 438 | The following five field specifiers are not drawn directly from the |
438 | data in struct stat, but are: | | 439 | data in struct stat, but are: |
439 | .Bl -tag -width Ds | | 440 | .Bl -tag -width Ds |
440 | .It Cm N | | 441 | .It Cm N |
441 | The name of the file. | | 442 | The name of the file. |
442 | .It Cm R | | 443 | .It Cm R |
443 | The absolute pathname corresponding to the file. | | 444 | The absolute pathname corresponding to the file. |
444 | .It Cm T | | 445 | .It Cm T |
445 | The file type, either as in | | 446 | The file type, either as in |
446 | .Ic ls -F | | 447 | .Ic ls -F |
447 | or in a more descriptive form if the sub field specifier | | 448 | or in a more descriptive form if the sub field specifier |
448 | .Cm H | | 449 | .Cm H |
449 | is given. | | 450 | is given. |
450 | .It Cm Y | | 451 | .It Cm Y |
451 | The target of a symbolic link. | | 452 | The target of a symbolic link. |
452 | .It Cm Z | | 453 | .It Cm Z |
453 | Expands to | | 454 | Expands to |
454 | .Dq Ar major , Ns Ar minor | | 455 | .Dq Ar major , Ns Ar minor |
455 | from the rdev field for character or block | | 456 | from the rdev field for character or block |
456 | special devices and gives size output for all others. | | 457 | special devices and gives size output for all others. |
457 | .El | | 458 | .El |
458 | .El | | 459 | .El |
459 | .Pp | | 460 | .Pp |
460 | Only the | | 461 | Only the |
461 | .Cm % | | 462 | .Cm % |
462 | and the field specifier are required. | | 463 | and the field specifier are required. |
463 | Most field specifiers default to | | 464 | Most field specifiers default to |
464 | .Cm U | | 465 | .Cm U |
465 | as an output form, with the | | 466 | as an output form, with the |
466 | exception of | | 467 | exception of |
467 | .Cm p | | 468 | .Cm p |
468 | which defaults to | | 469 | which defaults to |
469 | .Cm O ; | | 470 | .Cm O ; |
470 | .Cm a , m , | | 471 | .Cm a , m , |
471 | and | | 472 | and |
472 | .Cm c | | 473 | .Cm c |
473 | which default to | | 474 | which default to |
474 | .Cm D ; | | 475 | .Cm D ; |
475 | and | | 476 | and |
476 | .Cm Y , T , | | 477 | .Cm Y , T , |
477 | and | | 478 | and |
478 | .Cm N , | | 479 | .Cm N , |
479 | which default to | | 480 | which 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 |
484 | If no options are specified, the default format is | | 485 | If 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 |
488 | 0 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 | 0 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 |
491 | This example produces output very similar to that from | | 492 | This 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 |
495 | displays the time in a different format, and | | 496 | displays the time in a different format, and |
496 | .Xr find 1 | | 497 | .Xr find 1 |
497 | sometimes adds one or more spaces after the comma in | | 498 | sometimes adds one or more spaces after the comma in |
498 | .Dq Ar major , Ns Ar minor | | 499 | .Dq Ar major , Ns Ar minor |
499 | for device nodes): | | 500 | for 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 |
508 | This example produces output very similar to that from | | 509 | This 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 |
512 | adjusts the column spacing differently when listing multiple files, | | 513 | adjusts the column spacing differently when listing multiple files, |
513 | and | | 514 | and |
514 | .Xr ls 1 | | 515 | .Xr ls 1 |
515 | adds at least one space after the comma in | | 516 | adds at least one space after the comma in |
516 | .Dq Ar major , Ns Ar minor | | 517 | .Dq Ar major , Ns Ar minor |
517 | for device nodes): | | 518 | for 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 |
526 | Given a symbolic link | | 527 | Given a symbolic link |
527 | .Dq foo | | 528 | .Dq foo |
528 | that points from | | 529 | that points from |
529 | .Pa /tmp/foo | | 530 | .Pa /tmp/foo |
530 | to | | 531 | to |
531 | .Pa / , | | 532 | .Pa / , |
532 | you would use | | 533 | you would use |
533 | .Nm | | 534 | .Nm |
534 | as follows: | | 535 | as follows: |
535 | .Bd -literal -offset indent | | 536 | .Bd -literal -offset indent |
536 | > stat -F /tmp/foo | | 537 | > stat -F /tmp/foo |
537 | lrwxrwxrwx 1 jschauma cs 1 Apr 24 16:37:28 2002 /tmp/foo@ -> / | | 538 | lrwxrwxrwx 1 jschauma cs 1 Apr 24 16:37:28 2002 /tmp/foo@ -> / |
538 | | | 539 | |
539 | > stat -LF /tmp/foo | | 540 | > stat -LF /tmp/foo |
540 | drwxr-xr-x 16 root wheel 512 Apr 19 10:57:54 2002 /tmp/foo/ | | 541 | drwxr-xr-x 16 root wheel 512 Apr 19 10:57:54 2002 /tmp/foo/ |
541 | .Ed | | 542 | .Ed |
542 | .Pp | | 543 | .Pp |
543 | To initialize some shell-variables, you could use the | | 544 | To initialize some shell-variables, you could use the |
544 | .Fl s | | 545 | .Fl s |
545 | flag as follows: | | 546 | flag 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 |
550 | 1148 1015432481 | | 551 | 1148 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 |
555 | 1148 1015432481 | | 556 | 1148 1015432481 |
556 | .Ed | | 557 | .Ed |
557 | .Pp | | 558 | .Pp |
558 | In order to get a list of the kind of files including files pointed to if the | | 559 | In order to get a list of the kind of files including files pointed to if the |
559 | file is a symbolic link, you could use the following format: | | 560 | file 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 |
568 | In order to get a list of the devices, their types and the major and minor | | 569 | In order to get a list of the devices, their types and the major and minor |
569 | device numbers, formatted with tabs and linebreaks, you could use the | | 570 | device numbers, formatted with tabs and linebreaks, you could use the |
570 | following format: | | 571 | following format: |
571 | .Bd -literal -offset indent | | 572 | .Bd -literal -offset indent |
572 | stat -f "Name: %N%n%tType: %HT%n%tMajor: %Hr%n%tMinor: %Lr%n%n" /dev/* | | 573 | stat -f "Name: %N%n%tType: %HT%n%tMajor: %Hr%n%tMinor: %Lr%n%n" /dev/* |
573 | [...] | | 574 | [...] |
574 | Name: /dev/wt8 | | 575 | Name: /dev/wt8 |
575 | Type: Block Device | | 576 | Type: Block Device |
576 | Major: 3 | | 577 | Major: 3 |
577 | Minor: 8 | | 578 | Minor: 8 |
578 | | | 579 | |
579 | Name: /dev/zero | | 580 | Name: /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 |
585 | In order to determine the permissions set on a file separately, you could use | | 586 | In order to determine the permissions set on a file separately, you could use |
586 | the following format: | | 587 | the 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" . |
589 | drwxr-xr-x -> owner=rwx group=r-x other=r-x | | 590 | drwxr-xr-x -> owner=rwx group=r-x other=r-x |
590 | .Ed | | 591 | .Ed |
591 | .Pp | | 592 | .Pp |
592 | In order to determine the three files that have been modified most recently, | | 593 | In order to determine the three files that have been modified most recently, |
593 | you could use the following format: | | 594 | you 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- |
596 | Apr 25 11:47:00 2002 /tmp/blah | | 597 | Apr 25 11:47:00 2002 /tmp/blah |
597 | Apr 25 10:36:34 2002 /tmp/bar | | 598 | Apr 25 10:36:34 2002 /tmp/bar |
598 | Apr 24 16:47:35 2002 /tmp/foo | | 599 | Apr 24 16:47:35 2002 /tmp/foo |
599 | .Ed | | 600 | .Ed |
600 | .Pp | | 601 | .Pp |
601 | User names, group names, and file names that contain spaces | | 602 | User names, group names, and file names that contain spaces |
602 | or other special characters may be encoded in | | 603 | or other special characters may be encoded in |
603 | .Xr vis 3 | | 604 | .Xr vis 3 |
604 | style, using the | | 605 | style, using the |
605 | .Cm \&# | | 606 | .Cm \&# |
606 | modifier: | | 607 | modifier: |
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' |
610 | link\eswith\esspaces -> target\eswith\esspaces | | 611 | link\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 |
623 | The | | 624 | The |
624 | .Nm | | 625 | .Nm |
625 | utility appeared in | | 626 | utility appeared in |
626 | .Nx 1.6 . | | 627 | .Nx 1.6 . |
627 | .Sh AUTHORS | | 628 | .Sh AUTHORS |
628 | .An -nosplit | | 629 | .An -nosplit |
629 | The | | 630 | The |
630 | .Nm | | 631 | .Nm |
631 | utility was written by | | 632 | utility was written by |
632 | .An Andrew Brown | | 633 | .An Andrew Brown |
633 | .Aq atatat@NetBSD.org . | | 634 | .Aq atatat@NetBSD.org . |
634 | This man page was written by | | 635 | This man page was written by |
635 | .An Jan Schaumann | | 636 | .An Jan Schaumann |
636 | .Aq jschauma@NetBSD.org . | | 637 | .Aq jschauma@NetBSD.org . |