version 1.1, 2005/04/01 07:07:31 |
version 1.2, 2005/04/01 16:41:41 |
|
|
.Op Fl FLnq |
.Op Fl FLnq |
.Oo |
.Oo |
.Fl f Ar format | |
.Fl f Ar format | |
.Fl l | |
.Fl l | r | s | x |
.Fl r | |
|
.Fl s | |
|
.Fl x |
|
.Oc |
.Oc |
.Op Fl t Ar timefmt |
.Op Fl t Ar timefmt |
.Op Ar |
.Op Ar |
|
|
.Nm |
.Nm |
utility displays information about the file pointed to by |
utility displays information about the file pointed to by |
.Ar file . |
.Ar file . |
Read, write or execute permissions of the named file are not required, but |
Read, write, or execute permissions of the named file are not required, but |
all directories listed in the path name leading to the file must be |
all directories listed in the pathname leading to the file must be |
searchable. |
searchable. |
If no argument is given, |
If no argument is given, |
.Nm |
.Nm |
|
|
.Bl -tag -width Ds |
.Bl -tag -width Ds |
.It Fl F |
.It Fl F |
As in |
As in |
.Ic ls , |
.Xr ls 1 , |
display a slash (/) immediately after each pathname that is a directory, an |
display a slash (/) immediately after each pathname that is a directory, an |
asterisk (*) after each that is executable, an at sign (@) after each symbolic |
asterisk (*) after each that is executable, an at sign (@) after each symbolic |
link, a percent sign (%) after each whiteout, an equal sign (=) after each |
link, a percent sign (%) after each whiteout, an equal sign (=) after each |
|
|
.Fl F |
.Fl F |
implies |
implies |
.Fl l . |
.Fl l . |
|
.It Fl f Ar format |
|
Display information using the specified format. |
|
See the FORMATS section |
|
for a description of valid formats. |
.It Fl L |
.It Fl L |
Use |
Use |
.Xr stat 2 |
.Xr stat 2 |
|
|
if file is a symbolic link, and not to |
if file is a symbolic link, and not to |
.Ar file |
.Ar file |
itself. |
itself. |
|
.It Fl l |
|
Display output in |
|
.Ic ls Fl lT |
|
format. |
.It Fl n |
.It Fl n |
Do not force a newline to appear at the end of each piece of output. |
Do not force a newline to appear at the end of each piece of output. |
.It Fl q |
.It Fl q |
|
|
When run as |
When run as |
.Nm readlink , |
.Nm readlink , |
error messages are automatically suppressed. |
error messages are automatically suppressed. |
.It Fl f Ar format |
|
Display information using the specified format. |
|
See the FORMATS section |
|
for a description of valid formats. |
|
.It Fl l |
|
Display output in |
|
.Ic ls Fl lT |
|
format. |
|
.It Fl r |
.It Fl r |
Display raw information. |
Display raw information. |
That is, for all the fields in the stat-structure, |
That is, for all the fields in the stat-structure, |
display the raw, numerical value (for example, times in seconds since the |
display the raw, numerical value (for example, times in seconds since the |
epoch, etc.) |
Epoch, etc.). |
.It Fl s |
.It Fl s |
Display information in ``shell output'', suitable for initializing variables. |
Display information in ``shell output'', suitable for initializing variables. |
.It Fl x |
|
Display information in a more verbose way as known from some Linux |
|
distributions. |
|
.It Fl t Ar timefmt |
.It Fl t Ar timefmt |
Display timestamps using the specified format. |
Display timestamps using the specified format. |
This format is |
This format is |
passed directly to |
passed directly to |
.Xr strftime 3 . |
.Xr strftime 3 . |
|
.It Fl x |
|
Display information in a more verbose way as known from some Linux |
|
distributions. |
.El |
.El |
.Ss FORMATS |
.Ss FORMATS |
Format strings are similar to |
Format strings are similar to |
|
|
Displays the type of |
Displays the type of |
.Ar file . |
.Ar file . |
.It Cm Y |
.It Cm Y |
Insert a `` -\*[Gt] '' into the output. |
Insert a `` -\*(Gt '' into the output. |
Note that the default output format |
Note that the default output format |
for |
for |
.Cm Y |
.Cm Y |
|
|
.Ar file |
.Ar file |
resides. |
resides. |
.It Cm i |
.It Cm i |
.Ar file Ap s |
.Ar file Ns 's |
inode number. |
inode number. |
.It Cm p |
.It Cm p |
File type and permissions. |
File type and permissions. |
|
|
.Ar file . |
.Ar file . |
.It Cm u , g |
.It Cm u , g |
User-id and group-id of |
User-id and group-id of |
.Ar file Ap s |
.Ar file Ns 's |
owner. |
owner. |
.It Cm r |
.It Cm r |
Device number for character and block device special files. |
Device number for character and block device special files. |
.It Cm a , m , c |
.It Cm a , m , c |
The time |
The time |
.Ar file |
.Ar file |
was last accessed or modified, of when the inode was last changed. |
was last accessed or modified, or when the inode was last changed. |
.It Cm z |
.It Cm z |
The size of |
The size of |
.Ar file |
.Ar file |
|
|
.El |
.El |
.Pp |
.Pp |
The following four field specifiers are not drawn directly from the |
The following four field specifiers are not drawn directly from the |
data in struct stat, but are |
data in struct stat, but are: |
.Bl -tag -width Ds |
.Bl -tag -width Ds |
.It Cm N |
.It Cm N |
The name of the file. |
The name of the file. |
|
|
.Cm N , |
.Cm N , |
which default to |
which default to |
.Cm S . |
.Cm S . |
.Sh EXIT STATUS |
.Pp |
.Nm |
.Nm |
exits 0 on success, and \*[Gt]0 if an error occurred. |
exits 0 on success, and \*(Gt0 if an error occurred. |
.Sh EXAMPLES |
.Sh EXAMPLES |
Given a symbolic link ``foo'' that points from /tmp/foo to /, you would use |
Given a symbolic link ``foo'' that points from /tmp/foo to /, you would use |
.Nm |
.Nm |
as follows: |
as follows: |
.Bd -literal -offset indent |
.Bd -literal -offset indent |
\*[Gt] stat -F /tmp/foo |
\*(Gt stat -F /tmp/foo |
lrwxrwxrwx 1 jschauma cs 1 Apr 24 16:37:28 2002 /tmp/foo@ -\*[Gt] / |
lrwxrwxrwx 1 jschauma cs 1 Apr 24 16:37:28 2002 /tmp/foo@ -\*(Gt / |
|
|
\*[Gt] stat -LF /tmp/foo |
\*(Gt stat -LF /tmp/foo |
drwxr-xr-x 16 root wheel 512 Apr 19 10:57:54 2002 /tmp/foo/ |
drwxr-xr-x 16 root wheel 512 Apr 19 10:57:54 2002 /tmp/foo/ |
.Ed |
.Ed |
.Pp |
.Pp |
|
|
.Fl s |
.Fl s |
flag as follows: |
flag as follows: |
.Bd -literal -offset indent |
.Bd -literal -offset indent |
\*[Gt] csh |
\*(Gt csh |
% eval set `stat -s .cshrc` |
% eval set `stat -s .cshrc` |
% echo $st_size $st_mtimespec |
% echo $st_size $st_mtimespec |
1148 1015432481 |
1148 1015432481 |
|
|
\*[Gt] sh |
\*(Gt sh |
$ eval $(stat -s .profile) |
$ eval $(stat -s .profile) |
$ echo $st_size $st_mtimespec |
$ echo $st_size $st_mtimespec |
1148 1015432481 |
1148 1015432481 |
|
|
file is a symbolic link, you could use the following format: |
file is a symbolic link, you could use the following format: |
.Bd -literal -offset indent |
.Bd -literal -offset indent |
$ stat -f "%N: %HT%SY" /tmp/* |
$ stat -f "%N: %HT%SY" /tmp/* |
/tmp/bar: Symbolic Link -\*[Gt] /tmp/foo |
/tmp/bar: Symbolic Link -\*(Gt /tmp/foo |
/tmp/output25568: Regular File |
/tmp/output25568: Regular File |
/tmp/blah: Directory |
/tmp/blah: Directory |
/tmp/foo: Symbolic Link -\*[Gt] / |
/tmp/foo: Symbolic Link -\*(Gt / |
.Ed |
.Ed |
.Pp |
.Pp |
In order to get a list of the devices, their types and the major and minor |
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 |
device numbers, formatted with tabs and linebreaks, you could use the |
following format: |
following format: |
.Bd -literal -offset indent |
.Bd -literal -offset 4n |
stat -f "Name: %N%n%tType: %HT%n%tMajor: %Hr%n%tMinor: %Lr%n%n" /dev/* |
stat -f "Name: %N%n%tType: %HT%n%tMajor: %Hr%n%tMinor: %Lr%n%n" /dev/* |
[...] |
[...] |
Name: /dev/wt8 |
Name: /dev/wt8 |
|
|
In order to determine the permissions set on a file separately, you could use |
In order to determine the permissions set on a file separately, you could use |
the following format: |
the following format: |
.Bd -literal -offset indent |
.Bd -literal -offset indent |
\*[Gt] stat -f "%Sp -\*[Gt] owner=%SHp group=%SMp other=%SLp" . |
\*(Gt stat -f "%Sp -\*(Gt owner=%SHp group=%SMp other=%SLp" . |
drwxr-xr-x -\*[Gt] owner=rwx group=r-x other=r-x |
drwxr-xr-x -\*(Gt owner=rwx group=r-x other=r-x |
.Ed |
.Ed |
.Pp |
.Pp |
In order to determine the three files that have been modified most recently, |
In order to determine the three files that have been modified most recently, |
you could use the following format: |
you could use the following format: |
.Bd -literal -offset indent |
.Bd -literal -offset indent |
\*[Gt] stat -f "%m%t%Sm %N" /tmp/* | sort -rn | head -3 | cut -f2- |
\*(Gt stat -f "%m%t%Sm %N" /tmp/* | sort -rn | head -3 | cut -f2- |
Apr 25 11:47:00 2002 /tmp/blah |
Apr 25 11:47:00 2002 /tmp/blah |
Apr 25 10:36:34 2002 /tmp/bar |
Apr 25 10:36:34 2002 /tmp/bar |
Apr 24 16:47:35 2002 /tmp/foo |
Apr 24 16:47:35 2002 /tmp/foo |
|
|
The |
The |
.Nm |
.Nm |
utility was written by |
utility was written by |
.An Andrew Brown |
.An Andrew Brown Aq atatat@NetBSD.org . |
.Aq atatat@NetBSD.org . |
|
This man page was written by |
This man page was written by |
.An Jan Schaumann |
.An Jan Schaumann Aq jschauma@NetBSD.org . |
.Aq jschauma@NetBSD.org . |
|