stat
SYNOPSIS
stat [ -g ] [ -l ] [ -e ] [ -f format ] [ -t time_format ] [
-m time_format ] [ -a time_format ] [ -c time_format ] [ -q
mode_names ] [ -y type_names ] file ...
DESCRIPTION
Stat prints status information for each of the files speci-
fied. If a file name is `-', then status information about
the standard input is displayed.
The output can be specified by means of printf like format
specifications. If no format specifications are given, then
``ls -l'' like output is produced.
OPTIONS
-g List time fields in UTC (GMT) instead of local time.
-l For symbolic links list the status of the the file it
points to instead of the status of the link (i.e. fol-
low symbolic links).
-e Exit immediately with an error when stat can not be
performed on a file. If this flag is not given then
error messages are printed, but the program continues
to go through the list of files.
-f output format
Specify the output format.
-a time format
Specify the output format for the file access time
field.
-m time format
Specify the output format for the file modification
time field.
-c time format
Specify the output format for the file status change
time field.
-t time format
Specify the output format for the current time field.
-q mode names
Specify the English description of the file mode giving
a list of 24 strings. The strings are separated by an
arbitrary character and the list should start and end
with that character. The first three strings describe
the set user id, set group id and sticky modes. After
that, nine strings, the descriptions for read permis-
sion, write permission and execute permission, first
directories.
-y type names
Specify the English description of the file type giving
a list of seven strings. The list is given as in the
-q option and the strings are the descriptions to be
used for directories, block special files, character
special files, symbolic links, named pipes, sockets and
regular files. All types must be given, even if not
supported on a system.
Five format specifications can be given: one for the whole
output and four for the output format of different time
values. The format specification is a string. All charac-
ters in the format specification are printed except for
characters following a `%' sign. If the first character
after a `%' sign is an open bracket `(' then the characters
up to the matching closing bracket are taken as a printf
format specification that will be used to print the item
specified. A `%' sign in the printf format specification is
not needed. Note that some systems may not support some of
the options.
Characters following a `%' sign are converted in the global
output specification as follows:
v device the file resides on in decimal
i the file's inode number in decimal
p the file's protection in octal
P the file's protection in an ls -l like fashion
q the file's protection as a series of nine 0 or 1
digits. The default format specification for
printf is `%s' and applies to each individual
digit
Q the file's protection using an English descrip-
tion. The description can be optionaly specified
using the .q option. If the file is a symbolic
link and the -l option has not been given, nothing
is printed
l the number of links the file has in decimal
u the user id of the owner of the file in decimal
U the user id of the owner of the file as a string
g the group id of the owner of the file in decimal
G the group id of the owner of the file as a string
r the device identifier (only for special files)
s total byte size of the file in decimal
a last access time of file in seconds since 1970
m last modification time of file in seconds since
1970
c last status change time of file in seconds since
1970
t current time in seconds since 1970
A last access time of file as the string specified
C last status change time of file as the string
specified by the change time format
T current time as the string specified by the
current time format
z preferred blocksize for file I/O
b actual number of blocks allocated
n the name of the file
f a `/' for directories, `@' for symbolic links, `='
for AF_UNIX domain sockets and `*' for executable
files. If the name of a symbolic link or an arrow
is printed as a result of %L or %- then the `@' is
not printed.
F The type of the file is printed as one of the sym-
bols S_IFIDR, S_IFBLK, S_IFCHAR, S_IFLNK, S_IFIFO,
S_IFSOCK, S_IFREG for directories, block special
files, character special files, symbolic links,
FIFO special files, AF_UNIX domain sockets and
regular files.
Y The type of the file using an English description,
optionaly specified using the -y option
L if the file is a symbolic link, the contents of
the link
- if the file is a symbolic link, the character
sequence ` -> '
The default time format specification produces `ls -l' like
time output. Characters following a `%' sign are converted
in the time output specification as follows:
m the month number in decimal (1-12)
d the day of month number in decimal (1-31)
y the year in decimal (1900-...)
Y the year in decimal printed only if the time is
more that half a year older than the current time.
H the hour of the day in decimal (0-23)
M minutes in decimal (0-59)
S seconds in decimal (0-59)
T hours and minutes as 00:00 printed only if time is
less than half a year older than the current time.
(A note for pedants: If the time is exactly equal
to the current time minus half a year than hours
and minutes are printed.)
j the day of the year in decimal (0-365)
w the day of the week in decimal (Sunday is 0)
a the three letter abbreviation of the day of the
week
h the three letter abbreviation of the month
z the offset of the time from UTC (GMT) in seconds
Z abbreviation of the timezone name
D the letters DST if daylight savings time is in
effect
t The time in the form mmddhhmmyy. This form can be
used as an argument of the System V touch command.
stat -f '%P%(3d)l %(-8s)U %(8ld)s %M %n%-%L%F' *
Make depend in a makefile without modifying the permissions
of Makefile (Makefile can be read only from a version con-
trol system).
PERMS=`stat -f %p Makefile` ;\
chmod 600 Makefile ;\
mkdep $(FILES) ;\
chmod $$PERMS Makefile
An extremely verbose version of ls:
#!/bin/sh
T='%a %d %h %y %H:%M:%S'
stat -a "$T" -c "$T" -m "$T" -f '
File: %n
Type: %Y
Device: %v(0x%(x)v)
Inode: %i(0x%(x)i)
Potection: %Q
User: %U(%u)
Group: %G(%g)
File size: %s byte(s) %b block(s)
Last access: %A
Last change: %M
Status change: %C
' -y '
Directory
Block device
Character device
Symbolic link
Named pipe
Socket
Normal file
' $*
AUTHOR
(C) Copyright 1989 Diomidis D. Spinellis (dds@cc.ic.ac.uk).
All rights reserved.
SEE ALSO
ls(1), find(1), printf(3S)
BUGS
Not quite as many options as ls.
Man(1) output converted with
man2html