2005-06-26 14:16:46 +04:00
|
|
|
.\" $NetBSD: stat.1,v 1.18 2005/06/26 10:16:46 wiz Exp $
|
2002-04-27 20:37:19 +04:00
|
|
|
.\"
|
2005-06-23 07:13:24 +04:00
|
|
|
.\" Copyright (c) 2002-2005 The NetBSD Foundation, Inc.
|
2002-04-27 20:37:19 +04:00
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
.\" by Andrew Brown and Jan Schaumann.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the NetBSD
|
|
|
|
.\" Foundation, Inc. and its contributors.
|
|
|
|
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
.\" contributors may be used to endorse or promote products derived
|
|
|
|
.\" from this software without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
2005-06-23 07:13:24 +04:00
|
|
|
.Dd June 23, 2005
|
2002-04-28 21:44:43 +04:00
|
|
|
.Dt STAT 1
|
2002-04-27 20:37:19 +04:00
|
|
|
.Os
|
|
|
|
.Sh NAME
|
2002-07-08 22:48:42 +04:00
|
|
|
.Nm stat ,
|
|
|
|
.Nm readlink
|
2002-04-27 20:37:19 +04:00
|
|
|
.Nd display file status
|
|
|
|
.Sh SYNOPSIS
|
2002-04-28 21:44:43 +04:00
|
|
|
.Nm
|
2002-08-13 18:05:41 +04:00
|
|
|
.Op Fl FLnq
|
2002-04-27 20:37:19 +04:00
|
|
|
.Oo
|
|
|
|
.Fl f Ar format |
|
|
|
|
.Fl l |
|
|
|
|
.Fl r |
|
|
|
|
.Fl s |
|
|
|
|
.Fl x
|
|
|
|
.Oc
|
|
|
|
.Op Fl t Ar timefmt
|
|
|
|
.Op Ar
|
2002-07-08 22:48:42 +04:00
|
|
|
.Nm readlink
|
|
|
|
.Op Fl n
|
|
|
|
.Op Ar
|
2002-04-27 20:37:19 +04:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility displays information about the file pointed to by
|
|
|
|
.Ar file .
|
2004-09-02 03:26:10 +04:00
|
|
|
Read, write, or execute permissions of the named file are not required, but
|
2005-04-04 17:34:40 +04:00
|
|
|
all directories listed in the pathname leading to the file must be
|
2002-09-30 15:08:56 +04:00
|
|
|
searchable.
|
|
|
|
If no argument is given,
|
2002-04-27 20:37:19 +04:00
|
|
|
.Nm
|
|
|
|
displays information about the file descriptor for standard input.
|
|
|
|
.Pp
|
2002-07-08 22:48:42 +04:00
|
|
|
When invoked as
|
|
|
|
.Nm readlink ,
|
2002-09-30 15:08:56 +04:00
|
|
|
only the target of the symbolic link is printed.
|
|
|
|
If the given argument is not a symbolic link,
|
2002-07-08 22:48:42 +04:00
|
|
|
.Nm readlink
|
|
|
|
will print nothing and exit with an error.
|
|
|
|
.Pp
|
2002-04-27 20:37:19 +04:00
|
|
|
The information displayed is obtained by calling
|
2002-04-28 21:44:43 +04:00
|
|
|
.Xr lstat 2
|
2002-04-27 20:37:19 +04:00
|
|
|
with the given argument and evaluating the returned structure.
|
|
|
|
.Pp
|
|
|
|
The options are as follows:
|
2004-09-02 03:26:10 +04:00
|
|
|
.Bl -tag -width XFXformatXXX
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Fl F
|
|
|
|
As in
|
2005-04-04 17:34:40 +04:00
|
|
|
.Xr ls 1 ,
|
2004-09-02 03:26:10 +04:00
|
|
|
display a slash
|
|
|
|
.Pq Sq /
|
|
|
|
immediately after each pathname that is a directory, an
|
|
|
|
asterisk
|
|
|
|
.Pq Sq *
|
|
|
|
after each that is executable, an at sign
|
|
|
|
.Pq Sq @
|
|
|
|
after each symbolic link, a percent sign
|
|
|
|
.Pq Sq %
|
|
|
|
after each whiteout, an equal sign
|
|
|
|
.Pq Sq =
|
|
|
|
after each socket, and a vertical bar
|
|
|
|
.Pq Sq \&|
|
|
|
|
after each that is a FIFO.
|
2002-09-30 15:08:56 +04:00
|
|
|
The use of
|
2002-04-27 20:37:19 +04:00
|
|
|
.Fl F
|
|
|
|
implies
|
|
|
|
.Fl l .
|
2004-09-02 03:26:10 +04:00
|
|
|
.It Fl f Ar format
|
|
|
|
Display information using the specified format.
|
|
|
|
See the
|
|
|
|
.Sx FORMATS
|
|
|
|
section for a description of valid formats.
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Fl L
|
|
|
|
Use
|
|
|
|
.Xr stat 2
|
|
|
|
instead of
|
|
|
|
.Xr lstat 2 .
|
2002-04-28 21:44:43 +04:00
|
|
|
The information reported by
|
2002-04-27 20:37:19 +04:00
|
|
|
.Nm
|
|
|
|
will refer to the target of
|
|
|
|
.Ar file ,
|
|
|
|
if file is a symbolic link, and not to
|
|
|
|
.Ar file
|
|
|
|
itself.
|
2004-09-02 03:26:10 +04:00
|
|
|
.It Fl l
|
|
|
|
Display output in
|
|
|
|
.Ic ls Fl lT
|
|
|
|
format.
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Fl n
|
|
|
|
Do not force a newline to appear at the end of each piece of output.
|
2002-08-13 18:05:41 +04:00
|
|
|
.It Fl q
|
|
|
|
Suppress failure messages if calls to
|
|
|
|
.Xr stat 2
|
|
|
|
or
|
|
|
|
.Xr lstat 2
|
2002-09-30 15:08:56 +04:00
|
|
|
fail.
|
|
|
|
When run as
|
2002-08-13 18:05:41 +04:00
|
|
|
.Nm readlink ,
|
|
|
|
error messages are automatically suppressed.
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Fl r
|
2002-09-30 15:08:56 +04:00
|
|
|
Display raw information.
|
|
|
|
That is, for all the fields in the stat-structure,
|
2002-04-27 20:37:19 +04:00
|
|
|
display the raw, numerical value (for example, times in seconds since the
|
|
|
|
epoch, etc.)
|
|
|
|
.It Fl s
|
2004-09-02 03:26:10 +04:00
|
|
|
Display information in
|
|
|
|
.Dq shell output ,
|
|
|
|
suitable for initializing variables.
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Fl t Ar timefmt
|
2002-09-30 15:08:56 +04:00
|
|
|
Display timestamps using the specified format.
|
|
|
|
This format is
|
2002-04-27 20:37:19 +04:00
|
|
|
passed directly to
|
|
|
|
.Xr strftime 3 .
|
2004-09-02 03:26:10 +04:00
|
|
|
.It Fl x
|
|
|
|
Display information in a more verbose way as known from some Linux
|
|
|
|
distributions.
|
2002-04-27 20:37:19 +04:00
|
|
|
.El
|
2002-04-28 21:44:43 +04:00
|
|
|
.Ss FORMATS
|
2002-04-27 20:37:19 +04:00
|
|
|
Format strings are similar to
|
|
|
|
.Xr printf 3
|
|
|
|
formats in that they start with
|
|
|
|
.Cm % ,
|
|
|
|
are then followed by a sequence of formatting characters, and end in
|
|
|
|
a character that selects the field of the struct stat which is to be
|
2002-09-30 15:08:56 +04:00
|
|
|
formatted.
|
|
|
|
If the
|
2002-04-27 20:37:19 +04:00
|
|
|
.Cm %
|
|
|
|
is immediately followed by one of
|
|
|
|
.Cm n ,
|
|
|
|
.Cm t ,
|
|
|
|
.Cm % ,
|
2002-05-09 21:52:03 +04:00
|
|
|
or
|
|
|
|
.Cm @ ,
|
|
|
|
then a newline character, a tab character, a percent character,
|
|
|
|
or the current file number is printed, otherwise the string is
|
|
|
|
examined for the following:
|
2002-04-27 20:37:19 +04:00
|
|
|
.Pp
|
|
|
|
Any of the following optional flags:
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It Cm #
|
|
|
|
Selects an alternate output form for octal and hexadecimal output.
|
|
|
|
Non-zero octal output will have a leading zero, and non-zero
|
2004-09-02 03:26:10 +04:00
|
|
|
hexadecimal output will have
|
|
|
|
.Dq 0x
|
|
|
|
prepended to it.
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Cm +
|
|
|
|
Asserts that a sign indicating whether a number is positive or negative
|
2002-09-30 15:08:56 +04:00
|
|
|
should always be printed.
|
2004-09-02 03:26:10 +04:00
|
|
|
Non-negative numbers are not usually printed with a sign.
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Cm -
|
|
|
|
Aligns string output to the left of the field, instead of to the right.
|
|
|
|
.It Cm 0
|
|
|
|
Sets the fill character for left padding to the 0 character, instead of
|
|
|
|
a space.
|
|
|
|
.It space
|
2002-09-30 15:08:56 +04:00
|
|
|
Reserves a space at the front of non-negative signed output fields.
|
|
|
|
A
|
2002-04-27 20:37:19 +04:00
|
|
|
.Sq Cm +
|
|
|
|
overrides a space if both are used.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Then the following fields:
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It Cm size
|
|
|
|
An optional decimal digit string specifying the minimum field width.
|
|
|
|
.It Cm prec
|
|
|
|
An optional precision composed of a decimal point
|
|
|
|
.Sq Cm \&.
|
|
|
|
and a decimal digit string that indicates the maximum string length,
|
|
|
|
the number of digits to appear after the decimal point in floating point
|
|
|
|
output, or the minimum number of digits to appear in numeric output.
|
|
|
|
.It Cm fmt
|
2002-04-28 21:44:43 +04:00
|
|
|
An optional output format specifier which is one of
|
2002-04-27 20:37:19 +04:00
|
|
|
.Cm D ,
|
|
|
|
.Cm O ,
|
|
|
|
.Cm U ,
|
|
|
|
.Cm X ,
|
|
|
|
.Cm F ,
|
|
|
|
or
|
|
|
|
.Cm S .
|
|
|
|
These represent signed decimal output, octal output, unsigned decimal
|
|
|
|
output, hexadecimal output, floating point output, and string output,
|
2002-09-30 15:08:56 +04:00
|
|
|
respectively.
|
|
|
|
Some output formats do not apply to all fields.
|
2002-04-27 20:37:19 +04:00
|
|
|
Floating point output only applies to timespec fields (the
|
2002-04-28 21:44:43 +04:00
|
|
|
.Cm a ,
|
|
|
|
.Cm m ,
|
2002-04-27 20:37:19 +04:00
|
|
|
and
|
2002-04-28 21:44:43 +04:00
|
|
|
.Cm c
|
|
|
|
fields).
|
2002-04-27 20:37:19 +04:00
|
|
|
.Pp
|
|
|
|
The special output specifier
|
|
|
|
.Cm S
|
|
|
|
may be used to indicate that the output, if
|
2002-09-30 15:08:56 +04:00
|
|
|
applicable, should be in string format.
|
|
|
|
May be used in combination with
|
2002-04-27 20:37:19 +04:00
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It Cm amc
|
|
|
|
Display date in strftime(3) format.
|
|
|
|
.It Cm dr
|
|
|
|
Display actual device name.
|
|
|
|
.It Cm gu
|
|
|
|
Display group or user name.
|
|
|
|
.It Cm p
|
|
|
|
Display the mode of
|
|
|
|
.Ar file
|
|
|
|
as in
|
2002-04-28 21:21:33 +04:00
|
|
|
.Ic ls -lTd .
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Cm N
|
|
|
|
Displays the name of
|
|
|
|
.Ar file .
|
2002-04-28 21:44:43 +04:00
|
|
|
.It Cm T
|
2002-04-27 20:37:19 +04:00
|
|
|
Displays the type of
|
|
|
|
.Ar file .
|
|
|
|
.It Cm Y
|
2002-09-30 15:08:56 +04:00
|
|
|
Insert a `` -\*[Gt] '' into the output.
|
2004-09-02 03:26:10 +04:00
|
|
|
Note that the default output format for
|
2002-04-27 20:37:19 +04:00
|
|
|
.Cm Y
|
|
|
|
is a string, but if specified explicitly, these four characters are
|
|
|
|
prepended.
|
|
|
|
.El
|
|
|
|
.It Cm sub
|
2005-06-23 07:13:24 +04:00
|
|
|
An optional sub field specifier (high, middle, or low).
|
2004-09-02 03:26:10 +04:00
|
|
|
Only applies to the
|
2002-04-27 20:37:19 +04:00
|
|
|
.Cm p ,
|
|
|
|
.Cm d ,
|
|
|
|
.Cm r ,
|
2005-06-23 07:13:24 +04:00
|
|
|
.Cm T ,
|
|
|
|
.Cm N ,
|
2002-04-27 20:37:19 +04:00
|
|
|
and
|
2005-06-23 07:13:24 +04:00
|
|
|
.Cm z
|
2002-09-30 15:08:56 +04:00
|
|
|
output formats.
|
|
|
|
It can be one of the following:
|
2002-04-27 20:37:19 +04:00
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It Cm H
|
2004-09-02 03:26:10 +04:00
|
|
|
.Dq High
|
2005-06-23 07:13:24 +04:00
|
|
|
-- depending on the
|
|
|
|
.Cm datum :
|
|
|
|
.Bl -tag -compact -width door
|
|
|
|
.It Cm d , r
|
|
|
|
Major number for devices
|
|
|
|
.It Cm p
|
|
|
|
.Dq User
|
|
|
|
bits from the string form of permissions or the file
|
2004-09-02 03:26:10 +04:00
|
|
|
.Dq type
|
2005-06-23 07:13:24 +04:00
|
|
|
bits from the numeric forms
|
|
|
|
.It Cm T
|
|
|
|
The long output form of file type
|
|
|
|
.It Cm N
|
|
|
|
Directory path of the file, similar to what
|
2004-12-31 06:24:31 +03:00
|
|
|
.Xr dirname 1
|
2005-06-23 07:13:24 +04:00
|
|
|
would show
|
|
|
|
.It Cm z
|
|
|
|
File size, rounded to the nearest gigabyte
|
|
|
|
.El
|
|
|
|
.It Cm M
|
|
|
|
.Dq Middle
|
|
|
|
-- depending on the
|
|
|
|
.Cm datum :
|
|
|
|
.Bl -tag -compact -width door
|
|
|
|
.It Cm p
|
|
|
|
The
|
|
|
|
.Dq group
|
2005-06-26 14:16:46 +04:00
|
|
|
bits from the string form of permissions or the
|
2005-06-23 07:13:24 +04:00
|
|
|
.Dq suid ,
|
|
|
|
.Dq sgid ,
|
|
|
|
and
|
|
|
|
.Dq sticky
|
|
|
|
bits from the numeric forms
|
|
|
|
.It Cm z
|
|
|
|
File size, rounded to the nearest megabyte
|
|
|
|
.El
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Cm L
|
2004-09-02 03:26:10 +04:00
|
|
|
.Dq Low
|
2005-06-23 07:13:24 +04:00
|
|
|
-- depending on the
|
|
|
|
.Cm datum :
|
|
|
|
.Bl -tag -compact -width door
|
|
|
|
.It Cm r , d
|
|
|
|
Minor number for devices
|
|
|
|
.It Cm p
|
|
|
|
The
|
2004-09-02 03:26:10 +04:00
|
|
|
.Dq other
|
2005-06-23 07:13:24 +04:00
|
|
|
bits from the string form of permissions or the
|
2004-09-02 03:26:10 +04:00
|
|
|
.Dq user ,
|
|
|
|
.Dq group ,
|
|
|
|
and
|
|
|
|
.Dq other
|
2005-06-23 07:13:24 +04:00
|
|
|
bits from the numeric forms
|
|
|
|
.It Cm T
|
|
|
|
The
|
2002-04-27 20:37:19 +04:00
|
|
|
.Ic ls -F
|
2005-06-23 07:13:24 +04:00
|
|
|
style output character for file type (the use of
|
2002-04-27 20:37:19 +04:00
|
|
|
.Cm L
|
2005-06-23 07:13:24 +04:00
|
|
|
here is optional)
|
|
|
|
.It Cm N
|
|
|
|
Base filename of the file, similar to what
|
2004-12-31 06:24:31 +03:00
|
|
|
.Xr basename 1
|
2005-06-23 07:13:24 +04:00
|
|
|
would show
|
|
|
|
.It Cm z
|
|
|
|
File size, rounded to the nearest kilobyte
|
|
|
|
.El
|
2002-04-27 20:37:19 +04:00
|
|
|
.El
|
|
|
|
.It Cm datum
|
|
|
|
A required field specifier, being one of the following:
|
2004-09-02 03:26:10 +04:00
|
|
|
.Bl -tag -width 11n
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Cm d
|
|
|
|
Device upon which
|
|
|
|
.Ar file
|
|
|
|
resides.
|
|
|
|
.It Cm i
|
2002-04-28 21:44:43 +04:00
|
|
|
.Ar file Ap s
|
|
|
|
inode number.
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Cm p
|
|
|
|
File type and permissions.
|
|
|
|
.It Cm l
|
|
|
|
Number of hard links to
|
|
|
|
.Ar file .
|
|
|
|
.It Cm u , g
|
|
|
|
User-id and group-id of
|
2002-04-28 21:44:43 +04:00
|
|
|
.Ar file Ap s
|
|
|
|
owner.
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Cm r
|
|
|
|
Device number for character and block device special files.
|
2003-05-08 17:05:38 +04:00
|
|
|
.It Cm a , m , c , B
|
2002-04-27 20:37:19 +04:00
|
|
|
The time
|
|
|
|
.Ar file
|
2005-04-04 17:34:40 +04:00
|
|
|
was last accessed or modified, or when the inode was last changed, or
|
2003-05-08 17:05:38 +04:00
|
|
|
the birth time of the inode.
|
2002-04-27 20:37:19 +04:00
|
|
|
.It Cm z
|
|
|
|
The size of
|
|
|
|
.Ar file
|
|
|
|
in bytes.
|
|
|
|
.It Cm b
|
|
|
|
Number of blocks allocated for
|
|
|
|
.Ar file .
|
|
|
|
.It Cm k
|
|
|
|
Optimal file system I/O operation block size.
|
|
|
|
.It Cm f
|
|
|
|
User defined flags for
|
|
|
|
.Ar file .
|
|
|
|
.It Cm v
|
|
|
|
Inode generation number.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The following four field specifiers are not drawn directly from the
|
2005-04-04 17:34:40 +04:00
|
|
|
data in struct stat, but are:
|
2002-04-27 20:37:19 +04:00
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It Cm N
|
|
|
|
The name of the file.
|
|
|
|
.It Cm T
|
|
|
|
The file type, either as in
|
|
|
|
.Ic ls -F
|
|
|
|
or in a more descriptive form if the sub field specifier
|
|
|
|
.Cm H
|
|
|
|
is given.
|
|
|
|
.It Cm Y
|
|
|
|
The target of a symbolic link.
|
|
|
|
.It Cm Z
|
2004-09-02 03:26:10 +04:00
|
|
|
Expands to
|
|
|
|
.Dq major,minor
|
|
|
|
from the rdev field for character or block
|
2002-04-27 20:37:19 +04:00
|
|
|
special devices and gives size output for all others.
|
|
|
|
.El
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Only the
|
|
|
|
.Cm %
|
2002-09-30 15:08:56 +04:00
|
|
|
and the field specifier are required.
|
|
|
|
Most field specifiers default to
|
2002-04-27 20:37:19 +04:00
|
|
|
.Cm U
|
|
|
|
as an output form, with the
|
|
|
|
exception of
|
|
|
|
.Cm p
|
|
|
|
which defaults to
|
|
|
|
.Cm O ,
|
|
|
|
.Cm a , m ,
|
|
|
|
and
|
|
|
|
.Cm c
|
|
|
|
which default to
|
|
|
|
.Cm D ,
|
|
|
|
and
|
|
|
|
.Cm Y , T ,
|
|
|
|
and
|
|
|
|
.Cm N ,
|
|
|
|
which default to
|
|
|
|
.Cm S .
|
|
|
|
.Sh EXIT STATUS
|
|
|
|
.Nm
|
2002-04-28 21:44:43 +04:00
|
|
|
exits 0 on success, and \*[Gt]0 if an error occurred.
|
2002-04-27 20:37:19 +04:00
|
|
|
.Sh EXAMPLES
|
2004-09-02 03:26:10 +04:00
|
|
|
If no options are specified, the default format is
|
2004-09-02 02:18:20 +04:00
|
|
|
"%d %i %Sp %l %Su %Sg %r %z \\"%Sa\\" \\"%Sm\\" \\"%Sc\\" \\"%SB\\" %k %b %#Xf %N".
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
\*[Gt] stat /tmp/bar
|
|
|
|
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
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2004-09-02 03:26:10 +04:00
|
|
|
Given a symbolic link
|
|
|
|
.Dq foo
|
|
|
|
that points from
|
|
|
|
.Pa /tmp/foo
|
|
|
|
to
|
|
|
|
.Pa / ,
|
|
|
|
you would use
|
2002-04-27 20:37:19 +04:00
|
|
|
.Nm
|
|
|
|
as follows:
|
|
|
|
.Bd -literal -offset indent
|
2002-04-28 21:44:43 +04:00
|
|
|
\*[Gt] stat -F /tmp/foo
|
|
|
|
lrwxrwxrwx 1 jschauma cs 1 Apr 24 16:37:28 2002 /tmp/foo@ -\*[Gt] /
|
|
|
|
|
|
|
|
\*[Gt] stat -LF /tmp/foo
|
2003-02-21 21:50:10 +03:00
|
|
|
drwxr-xr-x 16 root wheel 512 Apr 19 10:57:54 2002 /tmp/foo/
|
2002-04-27 20:37:19 +04:00
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
To initialize some shell-variables, you could use the
|
|
|
|
.Fl s
|
|
|
|
flag as follows:
|
|
|
|
.Bd -literal -offset indent
|
2002-04-28 21:44:43 +04:00
|
|
|
\*[Gt] csh
|
2002-04-27 20:37:19 +04:00
|
|
|
% eval set `stat -s .cshrc`
|
2005-01-08 06:46:05 +03:00
|
|
|
% echo $st_size $st_mtime
|
2002-04-27 20:37:19 +04:00
|
|
|
1148 1015432481
|
2002-04-28 21:44:43 +04:00
|
|
|
|
|
|
|
\*[Gt] sh
|
2002-04-27 20:37:19 +04:00
|
|
|
$ eval $(stat -s .profile)
|
2005-01-08 06:46:05 +03:00
|
|
|
$ echo $st_size $st_mtime
|
2002-04-27 20:37:19 +04:00
|
|
|
1148 1015432481
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
In order to get a list of the kind of files including files pointed to if the
|
|
|
|
file is a symbolic link, you could use the following format:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
$ stat -f "%N: %HT%SY" /tmp/*
|
2002-04-28 21:44:43 +04:00
|
|
|
/tmp/bar: Symbolic Link -\*[Gt] /tmp/foo
|
2002-04-27 20:37:19 +04:00
|
|
|
/tmp/output25568: Regular File
|
|
|
|
/tmp/blah: Directory
|
2002-04-28 21:44:43 +04:00
|
|
|
/tmp/foo: Symbolic Link -\*[Gt] /
|
2002-04-27 20:37:19 +04:00
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
In order to get a list of the devices, their types and the major and minor
|
|
|
|
device numbers, formatted with tabs and linebreaks, you could use the
|
|
|
|
following format:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
stat -f "Name: %N%n%tType: %HT%n%tMajor: %Hr%n%tMinor: %Lr%n%n" /dev/*
|
|
|
|
[...]
|
|
|
|
Name: /dev/wt8
|
|
|
|
Type: Block Device
|
|
|
|
Major: 3
|
|
|
|
Minor: 8
|
2002-04-28 21:44:43 +04:00
|
|
|
|
2002-04-27 20:37:19 +04:00
|
|
|
Name: /dev/zero
|
|
|
|
Type: Character Device
|
|
|
|
Major: 2
|
|
|
|
Minor: 12
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
In order to determine the permissions set on a file separately, you could use
|
|
|
|
the following format:
|
|
|
|
.Bd -literal -offset indent
|
2002-04-28 21:44:43 +04:00
|
|
|
\*[Gt] stat -f "%Sp -\*[Gt] owner=%SHp group=%SMp other=%SLp" .
|
|
|
|
drwxr-xr-x -\*[Gt] owner=rwx group=r-x other=r-x
|
2002-04-27 20:37:19 +04:00
|
|
|
.Ed
|
|
|
|
.Pp
|
2002-04-28 21:44:43 +04:00
|
|
|
In order to determine the three files that have been modified most recently,
|
|
|
|
you could use the following format:
|
2002-04-27 20:37:19 +04:00
|
|
|
.Bd -literal -offset indent
|
2002-04-28 21:44:43 +04:00
|
|
|
\*[Gt] stat -f "%m%t%Sm %N" /tmp/* | sort -rn | head -3 | cut -f2-
|
2002-04-27 20:37:19 +04:00
|
|
|
Apr 25 11:47:00 2002 /tmp/blah
|
|
|
|
Apr 25 10:36:34 2002 /tmp/bar
|
|
|
|
Apr 24 16:47:35 2002 /tmp/foo
|
|
|
|
.Ed
|
|
|
|
.Sh SEE ALSO
|
2004-12-31 06:24:31 +03:00
|
|
|
.Xr basename 1 ,
|
|
|
|
.Xr dirname 1 ,
|
2005-06-26 14:16:46 +04:00
|
|
|
.Xr file 1 ,
|
2002-04-27 20:37:19 +04:00
|
|
|
.Xr ls 1 ,
|
|
|
|
.Xr lstat 2 ,
|
|
|
|
.Xr readlink 2 ,
|
|
|
|
.Xr stat 2 ,
|
|
|
|
.Xr printf 3 ,
|
|
|
|
.Xr strftime 3
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility appeared in
|
|
|
|
.Nx 1.6 .
|
|
|
|
.Sh AUTHORS
|
2004-09-02 03:26:10 +04:00
|
|
|
.An -nosplit
|
2002-04-27 20:37:19 +04:00
|
|
|
The
|
|
|
|
.Nm
|
2003-02-14 18:59:16 +03:00
|
|
|
utility was written by
|
|
|
|
.An Andrew Brown
|
|
|
|
.Aq atatat@NetBSD.org .
|
|
|
|
This man page was written by
|
|
|
|
.An Jan Schaumann
|
|
|
|
.Aq jschauma@NetBSD.org .
|