1*0a6a1f1dSLionel Sambuc.\" $NetBSD: stat.1,v 1.37 2014/04/13 01:45:34 snj Exp $ 249cab1c7SVivek Prakash.\" 3474b24f9SLionel Sambuc.\" Copyright (c) 2002-2011 The NetBSD Foundation, Inc. 449cab1c7SVivek Prakash.\" All rights reserved. 549cab1c7SVivek Prakash.\" 649cab1c7SVivek Prakash.\" This code is derived from software contributed to The NetBSD Foundation 749cab1c7SVivek Prakash.\" by Andrew Brown and Jan Schaumann. 849cab1c7SVivek Prakash.\" 949cab1c7SVivek Prakash.\" Redistribution and use in source and binary forms, with or without 1049cab1c7SVivek Prakash.\" modification, are permitted provided that the following conditions 1149cab1c7SVivek Prakash.\" are met: 1249cab1c7SVivek Prakash.\" 1. Redistributions of source code must retain the above copyright 1349cab1c7SVivek Prakash.\" notice, this list of conditions and the following disclaimer. 1449cab1c7SVivek Prakash.\" 2. Redistributions in binary form must reproduce the above copyright 1549cab1c7SVivek Prakash.\" notice, this list of conditions and the following disclaimer in the 1649cab1c7SVivek Prakash.\" documentation and/or other materials provided with the distribution. 1749cab1c7SVivek Prakash.\" 1849cab1c7SVivek Prakash.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1949cab1c7SVivek Prakash.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2049cab1c7SVivek Prakash.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2149cab1c7SVivek Prakash.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2249cab1c7SVivek Prakash.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2349cab1c7SVivek Prakash.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2449cab1c7SVivek Prakash.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2549cab1c7SVivek Prakash.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2649cab1c7SVivek Prakash.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2749cab1c7SVivek Prakash.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2849cab1c7SVivek Prakash.\" POSSIBILITY OF SUCH DAMAGE. 2949cab1c7SVivek Prakash.\" 3084d9c625SLionel Sambuc.Dd December 2, 2012 3149cab1c7SVivek Prakash.Dt STAT 1 3249cab1c7SVivek Prakash.Os 3349cab1c7SVivek Prakash.Sh NAME 3449cab1c7SVivek Prakash.Nm stat , 3549cab1c7SVivek Prakash.Nm readlink 3649cab1c7SVivek Prakash.Nd display file status 3749cab1c7SVivek Prakash.Sh SYNOPSIS 3849cab1c7SVivek Prakash.Nm 3949cab1c7SVivek Prakash.Op Fl FLnq 4049cab1c7SVivek Prakash.Oo 4149cab1c7SVivek Prakash.Fl f Ar format | 4249cab1c7SVivek Prakash.Fl l | 4349cab1c7SVivek Prakash.Fl r | 4449cab1c7SVivek Prakash.Fl s | 4549cab1c7SVivek Prakash.Fl x 4649cab1c7SVivek Prakash.Oc 4749cab1c7SVivek Prakash.Op Fl t Ar timefmt 4849cab1c7SVivek Prakash.Op Ar 4949cab1c7SVivek Prakash.Nm readlink 50474b24f9SLionel Sambuc.Op Fl fnqsv 5149cab1c7SVivek Prakash.Op Ar 5249cab1c7SVivek Prakash.Sh DESCRIPTION 5349cab1c7SVivek PrakashThe 5449cab1c7SVivek Prakash.Nm 5549cab1c7SVivek Prakashutility displays information about the file pointed to by 5649cab1c7SVivek Prakash.Ar file . 5749cab1c7SVivek PrakashRead, write, or execute permissions of the named file are not required, but 5849cab1c7SVivek Prakashall directories listed in the pathname leading to the file must be 5949cab1c7SVivek Prakashsearchable. 6049cab1c7SVivek PrakashIf no argument is given, 6149cab1c7SVivek Prakash.Nm 6249cab1c7SVivek Prakashdisplays information about the file descriptor for standard input. 6349cab1c7SVivek Prakash.Pp 6449cab1c7SVivek PrakashWhen invoked as 6549cab1c7SVivek Prakash.Nm readlink , 6649cab1c7SVivek Prakashonly the target of the symbolic link is printed. 6749cab1c7SVivek PrakashIf the given argument is not a symbolic link and the 6849cab1c7SVivek Prakash.Fl f 6949cab1c7SVivek Prakashoption is not specified, 7049cab1c7SVivek Prakash.Nm readlink 7149cab1c7SVivek Prakashwill print nothing and exit with an error. 7249cab1c7SVivek PrakashIf the 7349cab1c7SVivek Prakash.Fl f 7449cab1c7SVivek Prakashoption is specified, the output is canonicalized by following every symlink 7549cab1c7SVivek Prakashin every component of the given path recursively. 7649cab1c7SVivek Prakash.Nm readlink 7749cab1c7SVivek Prakashwill resolve both absolute and relative paths, and return the absolute pathname 7849cab1c7SVivek Prakashcorresponding to 7949cab1c7SVivek Prakash.Ar file . 8049cab1c7SVivek PrakashIn this case, the argument does not need to be a symbolic link. 8149cab1c7SVivek Prakash.Pp 8249cab1c7SVivek PrakashThe information displayed is obtained by calling 8349cab1c7SVivek Prakash.Xr lstat 2 8449cab1c7SVivek Prakashwith the given argument and evaluating the returned structure. 8549cab1c7SVivek PrakashThe default format displays the 8649cab1c7SVivek Prakash.Fa st_dev , 8749cab1c7SVivek Prakash.Fa st_ino , 8849cab1c7SVivek Prakash.Fa st_mode , 8949cab1c7SVivek Prakash.Fa st_nlink , 9049cab1c7SVivek Prakash.Fa st_uid , 9149cab1c7SVivek Prakash.Fa st_gid , 9249cab1c7SVivek Prakash.Fa st_rdev , 9349cab1c7SVivek Prakash.Fa st_size , 9449cab1c7SVivek Prakash.Fa st_atime , 9549cab1c7SVivek Prakash.Fa st_mtime , 9649cab1c7SVivek Prakash.Fa st_ctime , 9749cab1c7SVivek Prakash.Fa st_birthtime , 9849cab1c7SVivek Prakash.Fa st_blksize , 9949cab1c7SVivek Prakash.Fa st_blocks , 10049cab1c7SVivek Prakashand 10149cab1c7SVivek Prakash.Fa st_flags 10249cab1c7SVivek Prakashfields, in that order. 10349cab1c7SVivek Prakash.Pp 10449cab1c7SVivek PrakashThe options are as follows: 10549cab1c7SVivek Prakash.Bl -tag -width XFXformatXXX 10649cab1c7SVivek Prakash.It Fl F 10749cab1c7SVivek PrakashAs in 10849cab1c7SVivek Prakash.Xr ls 1 , 10949cab1c7SVivek Prakashdisplay a slash 11049cab1c7SVivek Prakash.Pq Sq / 11149cab1c7SVivek Prakashimmediately after each pathname that is a directory, an 11249cab1c7SVivek Prakashasterisk 11349cab1c7SVivek Prakash.Pq Sq * 11449cab1c7SVivek Prakashafter each that is executable, an at sign 11549cab1c7SVivek Prakash.Pq Sq @ 11649cab1c7SVivek Prakashafter each symbolic link, a percent sign 11749cab1c7SVivek Prakash.Pq Sq % 11849cab1c7SVivek Prakashafter each whiteout, an equal sign 11949cab1c7SVivek Prakash.Pq Sq = 12049cab1c7SVivek Prakashafter each socket, and a vertical bar 12149cab1c7SVivek Prakash.Pq Sq \&| 12249cab1c7SVivek Prakashafter each that is a FIFO. 12349cab1c7SVivek PrakashThe use of 12449cab1c7SVivek Prakash.Fl F 12549cab1c7SVivek Prakashimplies 12649cab1c7SVivek Prakash.Fl l . 12749cab1c7SVivek Prakash.It Fl f Ar format 12849cab1c7SVivek PrakashDisplay information using the specified format. 12949cab1c7SVivek PrakashSee the 13049cab1c7SVivek Prakash.Sx FORMATS 13149cab1c7SVivek Prakashsection for a description of valid formats. 13249cab1c7SVivek Prakash.It Fl L 13349cab1c7SVivek PrakashUse 13449cab1c7SVivek Prakash.Xr stat 2 13549cab1c7SVivek Prakashinstead of 13649cab1c7SVivek Prakash.Xr lstat 2 . 13749cab1c7SVivek PrakashThe information reported by 13849cab1c7SVivek Prakash.Nm 13949cab1c7SVivek Prakashwill refer to the target of 14049cab1c7SVivek Prakash.Ar file , 14149cab1c7SVivek Prakashif file is a symbolic link, and not to 14249cab1c7SVivek Prakash.Ar file 14349cab1c7SVivek Prakashitself. 14449cab1c7SVivek Prakash.It Fl l 14549cab1c7SVivek PrakashDisplay output in 14649cab1c7SVivek Prakash.Ic ls Fl lT 14749cab1c7SVivek Prakashformat. 14849cab1c7SVivek Prakash.It Fl n 14949cab1c7SVivek PrakashDo not force a newline to appear at the end of each piece of output. 15049cab1c7SVivek Prakash.It Fl q 15149cab1c7SVivek PrakashSuppress failure messages if calls to 15249cab1c7SVivek Prakash.Xr stat 2 15349cab1c7SVivek Prakashor 15449cab1c7SVivek Prakash.Xr lstat 2 15549cab1c7SVivek Prakashfail. 15649cab1c7SVivek PrakashWhen run as 15749cab1c7SVivek Prakash.Nm readlink , 15849cab1c7SVivek Prakasherror messages are automatically suppressed. 15949cab1c7SVivek Prakash.It Fl r 16049cab1c7SVivek PrakashDisplay raw information. 16149cab1c7SVivek PrakashThat is, for all the fields in the stat-structure, 16249cab1c7SVivek Prakashdisplay the raw, numerical value (for example, times in seconds since the 16349cab1c7SVivek Prakashepoch, etc.) 16449cab1c7SVivek Prakash.It Fl s 16549cab1c7SVivek PrakashDisplay information in 16649cab1c7SVivek Prakash.Dq shell output , 16749cab1c7SVivek Prakashsuitable for initializing variables. 168474b24f9SLionel SambucWhen run as 169474b24f9SLionel Sambuc.Nm readlink , 170474b24f9SLionel Sambucsuppress error messages. 17184d9c625SLionel SambucThis is equivalent to specifying 17284d9c625SLionel Sambuc.Bd -literal 17384d9c625SLionel SambucFMT="st_dev=%d st_ino=%i st_mode=%#p st_nlink=%l st_uid=%u st_gid=%g" 17484d9c625SLionel SambucFMT="$FMT st_rdev=%r st_size=%z st_atime=%Sa st_mtime=%Sm st_ctime=%Sc" 17584d9c625SLionel SambucFMT="$FMT st_birthtime=%SB st_blksize=%k st_blocks=%b st_flags=%f" 17684d9c625SLionel Sambucstat -t %s -f "$FMT" . 17784d9c625SLionel Sambuc.Ed 17884d9c625SLionel SambucNote that if you use a timeformat that contains embedded whitespace or shell 17984d9c625SLionel Sambucmeta-characters you will need to include appropriate quoting so the 18084d9c625SLionel Sambuc.Fl s 18184d9c625SLionel Sambucoutput remains valid. 18249cab1c7SVivek Prakash.It Fl t Ar timefmt 18349cab1c7SVivek PrakashDisplay timestamps using the specified format. 18449cab1c7SVivek PrakashThis format is 18549cab1c7SVivek Prakashpassed directly to 18649cab1c7SVivek Prakash.Xr strftime 3 . 187474b24f9SLionel Sambuc.It Fl v 188474b24f9SLionel SambucTurn off quiet mode. 18949cab1c7SVivek Prakash.It Fl x 19049cab1c7SVivek PrakashDisplay information in a more verbose way as known from some Linux 19149cab1c7SVivek Prakashdistributions. 19249cab1c7SVivek Prakash.El 19349cab1c7SVivek Prakash.Ss FORMATS 19449cab1c7SVivek PrakashFormat strings are similar to 19549cab1c7SVivek Prakash.Xr printf 3 19649cab1c7SVivek Prakashformats in that they start with 19749cab1c7SVivek Prakash.Cm % , 19849cab1c7SVivek Prakashare then followed by a sequence of formatting characters, and end in 19949cab1c7SVivek Prakasha character that selects the field of the struct stat which is to be 20049cab1c7SVivek Prakashformatted. 20149cab1c7SVivek PrakashIf the 20249cab1c7SVivek Prakash.Cm % 20349cab1c7SVivek Prakashis immediately followed by one of 20449cab1c7SVivek Prakash.Cm n , 20549cab1c7SVivek Prakash.Cm t , 20649cab1c7SVivek Prakash.Cm % , 20749cab1c7SVivek Prakashor 20849cab1c7SVivek Prakash.Cm @ , 20949cab1c7SVivek Prakashthen a newline character, a tab character, a percent character, 21049cab1c7SVivek Prakashor the current file number is printed, otherwise the string is 21149cab1c7SVivek Prakashexamined for the following: 21249cab1c7SVivek Prakash.Pp 21349cab1c7SVivek PrakashAny of the following optional flags: 21449cab1c7SVivek Prakash.Bl -tag -width Ds 21549cab1c7SVivek Prakash.It Cm # 216474b24f9SLionel SambucSelects an alternate output form for string, octal and hexadecimal output. 217474b24f9SLionel SambucString output will be encoded in 218474b24f9SLionel Sambuc.Xr vis 3 219474b24f9SLionel Sambucstyle. 220474b24f9SLionel SambucNon-zero octal output will have a leading zero. 221474b24f9SLionel SambucNon-zero hexadecimal output will have 22249cab1c7SVivek Prakash.Dq 0x 22349cab1c7SVivek Prakashprepended to it. 22449cab1c7SVivek Prakash.It Cm + 22549cab1c7SVivek PrakashAsserts that a sign indicating whether a number is positive or negative 22649cab1c7SVivek Prakashshould always be printed. 22749cab1c7SVivek PrakashNon-negative numbers are not usually printed with a sign. 22849cab1c7SVivek Prakash.It Cm - 22949cab1c7SVivek PrakashAligns string output to the left of the field, instead of to the right. 23049cab1c7SVivek Prakash.It Cm 0 23149cab1c7SVivek PrakashSets the fill character for left padding to the 0 character, instead of 23249cab1c7SVivek Prakasha space. 23349cab1c7SVivek Prakash.It space 23449cab1c7SVivek PrakashReserves a space at the front of non-negative signed output fields. 23549cab1c7SVivek PrakashA 23649cab1c7SVivek Prakash.Sq Cm + 23749cab1c7SVivek Prakashoverrides a space if both are used. 23849cab1c7SVivek Prakash.El 23949cab1c7SVivek Prakash.Pp 24049cab1c7SVivek PrakashThen the following fields: 24149cab1c7SVivek Prakash.Bl -tag -width Ds 24249cab1c7SVivek Prakash.It Cm size 24349cab1c7SVivek PrakashAn optional decimal digit string specifying the minimum field width. 24449cab1c7SVivek Prakash.It Cm prec 24549cab1c7SVivek PrakashAn optional precision composed of a decimal point 24649cab1c7SVivek Prakash.Sq Cm \&. 24749cab1c7SVivek Prakashand a decimal digit string that indicates the maximum string length, 24849cab1c7SVivek Prakashthe number of digits to appear after the decimal point in floating point 24949cab1c7SVivek Prakashoutput, or the minimum number of digits to appear in numeric output. 25049cab1c7SVivek Prakash.It Cm fmt 25149cab1c7SVivek PrakashAn optional output format specifier which is one of 25249cab1c7SVivek Prakash.Cm D , 25349cab1c7SVivek Prakash.Cm O , 25449cab1c7SVivek Prakash.Cm U , 25549cab1c7SVivek Prakash.Cm X , 25649cab1c7SVivek Prakash.Cm F , 25749cab1c7SVivek Prakashor 25849cab1c7SVivek Prakash.Cm S . 25949cab1c7SVivek PrakashThese represent signed decimal output, octal output, unsigned decimal 26049cab1c7SVivek Prakashoutput, hexadecimal output, floating point output, and string output, 26149cab1c7SVivek Prakashrespectively. 26249cab1c7SVivek PrakashSome output formats do not apply to all fields. 26349cab1c7SVivek PrakashFloating point output only applies to timespec fields (the 26449cab1c7SVivek Prakash.Cm a , 26549cab1c7SVivek Prakash.Cm m , 26649cab1c7SVivek Prakashand 26749cab1c7SVivek Prakash.Cm c 26849cab1c7SVivek Prakashfields). 26949cab1c7SVivek Prakash.Pp 27049cab1c7SVivek PrakashThe special output specifier 27149cab1c7SVivek Prakash.Cm S 27249cab1c7SVivek Prakashmay be used to indicate that the output, if 27349cab1c7SVivek Prakashapplicable, should be in string format. 27449cab1c7SVivek PrakashMay be used in combination with 27549cab1c7SVivek Prakash.Bl -tag -width Ds 27649cab1c7SVivek Prakash.It Cm amc 27749cab1c7SVivek PrakashDisplay date in strftime(3) format. 27849cab1c7SVivek Prakash.It Cm dr 27949cab1c7SVivek PrakashDisplay actual device name. 28049cab1c7SVivek Prakash.It Cm gu 28149cab1c7SVivek PrakashDisplay group or user name. 28249cab1c7SVivek Prakash.It Cm p 28349cab1c7SVivek PrakashDisplay the mode of 28449cab1c7SVivek Prakash.Ar file 28549cab1c7SVivek Prakashas in 28649cab1c7SVivek Prakash.Ic ls -lTd . 28749cab1c7SVivek Prakash.It Cm N 28849cab1c7SVivek PrakashDisplays the name of 28949cab1c7SVivek Prakash.Ar file . 29049cab1c7SVivek Prakash.It Cm T 29149cab1c7SVivek PrakashDisplays the type of 29249cab1c7SVivek Prakash.Ar file . 29349cab1c7SVivek Prakash.It Cm Y 29449cab1c7SVivek PrakashInsert a `` -\*[Gt] '' into the output. 29549cab1c7SVivek PrakashNote that the default output format for 29649cab1c7SVivek Prakash.Cm Y 29749cab1c7SVivek Prakashis a string, but if specified explicitly, these four characters are 29849cab1c7SVivek Prakashprepended. 29949cab1c7SVivek Prakash.El 30049cab1c7SVivek Prakash.It Cm sub 30149cab1c7SVivek PrakashAn optional sub field specifier (high, middle, or low). 30249cab1c7SVivek PrakashOnly applies to the 30349cab1c7SVivek Prakash.Cm p , 30449cab1c7SVivek Prakash.Cm d , 30549cab1c7SVivek Prakash.Cm r , 30649cab1c7SVivek Prakash.Cm T , 30749cab1c7SVivek Prakash.Cm N , 30849cab1c7SVivek Prakashand 30949cab1c7SVivek Prakash.Cm z 31049cab1c7SVivek Prakashoutput formats. 31149cab1c7SVivek PrakashIt can be one of the following: 31249cab1c7SVivek Prakash.Bl -tag -width Ds 31349cab1c7SVivek Prakash.It Cm H 31449cab1c7SVivek Prakash.Dq High 31549cab1c7SVivek Prakash-- depending on the 31649cab1c7SVivek Prakash.Cm datum : 31749cab1c7SVivek Prakash.Bl -tag -compact -width door 31849cab1c7SVivek Prakash.It Cm d , r 31949cab1c7SVivek PrakashMajor number for devices 32049cab1c7SVivek Prakash.It Cm p 32149cab1c7SVivek Prakash.Dq User 32249cab1c7SVivek Prakashbits from the string form of permissions or the file 32349cab1c7SVivek Prakash.Dq type 32449cab1c7SVivek Prakashbits from the numeric forms 32549cab1c7SVivek Prakash.It Cm T 32649cab1c7SVivek PrakashThe long output form of file type 32749cab1c7SVivek Prakash.It Cm N 32849cab1c7SVivek PrakashDirectory path of the file, similar to what 32949cab1c7SVivek Prakash.Xr dirname 1 33049cab1c7SVivek Prakashwould show 33149cab1c7SVivek Prakash.It Cm z 33249cab1c7SVivek PrakashFile size, rounded to the nearest gigabyte 33349cab1c7SVivek Prakash.El 33449cab1c7SVivek Prakash.It Cm M 33549cab1c7SVivek Prakash.Dq Middle 33649cab1c7SVivek Prakash-- depending on the 33749cab1c7SVivek Prakash.Cm datum : 33849cab1c7SVivek Prakash.Bl -tag -compact -width door 33949cab1c7SVivek Prakash.It Cm p 34049cab1c7SVivek PrakashThe 34149cab1c7SVivek Prakash.Dq group 34249cab1c7SVivek Prakashbits from the string form of permissions or the 34349cab1c7SVivek Prakash.Dq suid , 34449cab1c7SVivek Prakash.Dq sgid , 34549cab1c7SVivek Prakashand 34649cab1c7SVivek Prakash.Dq sticky 34749cab1c7SVivek Prakashbits from the numeric forms 34849cab1c7SVivek Prakash.It Cm z 34949cab1c7SVivek PrakashFile size, rounded to the nearest megabyte 35049cab1c7SVivek Prakash.El 35149cab1c7SVivek Prakash.It Cm L 35249cab1c7SVivek Prakash.Dq Low 35349cab1c7SVivek Prakash-- depending on the 35449cab1c7SVivek Prakash.Cm datum : 35549cab1c7SVivek Prakash.Bl -tag -compact -width door 35649cab1c7SVivek Prakash.It Cm r , d 35749cab1c7SVivek PrakashMinor number for devices 35849cab1c7SVivek Prakash.It Cm p 35949cab1c7SVivek PrakashThe 36049cab1c7SVivek Prakash.Dq other 36149cab1c7SVivek Prakashbits from the string form of permissions or the 36249cab1c7SVivek Prakash.Dq user , 36349cab1c7SVivek Prakash.Dq group , 36449cab1c7SVivek Prakashand 36549cab1c7SVivek Prakash.Dq other 36649cab1c7SVivek Prakashbits from the numeric forms 36749cab1c7SVivek Prakash.It Cm T 36849cab1c7SVivek PrakashThe 36949cab1c7SVivek Prakash.Ic ls -F 37049cab1c7SVivek Prakashstyle output character for file type (the use of 37149cab1c7SVivek Prakash.Cm L 37249cab1c7SVivek Prakashhere is optional) 37349cab1c7SVivek Prakash.It Cm N 37449cab1c7SVivek PrakashBase filename of the file, similar to what 37549cab1c7SVivek Prakash.Xr basename 1 37649cab1c7SVivek Prakashwould show 37749cab1c7SVivek Prakash.It Cm z 37849cab1c7SVivek PrakashFile size, rounded to the nearest kilobyte 37949cab1c7SVivek Prakash.El 38049cab1c7SVivek Prakash.El 38149cab1c7SVivek Prakash.It Cm datum 38249cab1c7SVivek PrakashA required field specifier, being one of the following: 38349cab1c7SVivek Prakash.Bl -tag -width 11n 38449cab1c7SVivek Prakash.It Cm d 38549cab1c7SVivek PrakashDevice upon which 38649cab1c7SVivek Prakash.Ar file 38749cab1c7SVivek Prakashresides 38849cab1c7SVivek Prakash.Pq Fa st_dev . 38949cab1c7SVivek Prakash.It Cm i 39049cab1c7SVivek Prakash.Ar file Ap s 39149cab1c7SVivek Prakashinode number 39249cab1c7SVivek Prakash.Pq Fa st_ino . 39349cab1c7SVivek Prakash.It Cm p 39449cab1c7SVivek PrakashFile type and permissions 39549cab1c7SVivek Prakash.Pq Fa st_mode . 39649cab1c7SVivek Prakash.It Cm l 39749cab1c7SVivek PrakashNumber of hard links to 39849cab1c7SVivek Prakash.Ar file 39949cab1c7SVivek Prakash.Pq Fa st_nlink . 40049cab1c7SVivek Prakash.It Cm u , g 40149cab1c7SVivek PrakashUser-id and group-id of 40249cab1c7SVivek Prakash.Ar file Ap s 40349cab1c7SVivek Prakashowner 40449cab1c7SVivek Prakash.Pq Fa st_uid , st_gid . 40549cab1c7SVivek Prakash.It Cm r 40649cab1c7SVivek PrakashDevice number for character and block device special files 40749cab1c7SVivek Prakash.Pq Fa st_rdev . 40849cab1c7SVivek Prakash.It Cm a , m , c , B 40949cab1c7SVivek PrakashThe time 41049cab1c7SVivek Prakash.Ar file 41149cab1c7SVivek Prakashwas last accessed or modified, or when the inode was last changed, or 41249cab1c7SVivek Prakashthe birth time of the inode 41349cab1c7SVivek Prakash.Pq Fa st_atime , st_mtime , st_ctime, st_birthtime . 41449cab1c7SVivek Prakash.It Cm z 41549cab1c7SVivek PrakashThe size of 41649cab1c7SVivek Prakash.Ar file 41749cab1c7SVivek Prakashin bytes 41849cab1c7SVivek Prakash.Pq Fa st_size . 41949cab1c7SVivek Prakash.It Cm b 42049cab1c7SVivek PrakashNumber of blocks allocated for 42149cab1c7SVivek Prakash.Ar file 42249cab1c7SVivek Prakash.Pq Fa st_blocks . 42349cab1c7SVivek Prakash.It Cm k 42449cab1c7SVivek PrakashOptimal file system I/O operation block size 42549cab1c7SVivek Prakash.Pq Fa st_blksize . 42649cab1c7SVivek Prakash.It Cm f 42749cab1c7SVivek PrakashUser defined flags for 42849cab1c7SVivek Prakash.Ar file 42949cab1c7SVivek Prakash.Pq Fa st_flags . 43049cab1c7SVivek Prakash.It Cm v 43149cab1c7SVivek PrakashInode generation number 43249cab1c7SVivek Prakash.Pq Fa st_gen . 43349cab1c7SVivek Prakash.El 43449cab1c7SVivek Prakash.Pp 43549cab1c7SVivek PrakashThe following five field specifiers are not drawn directly from the 43649cab1c7SVivek Prakashdata in struct stat, but are: 43749cab1c7SVivek Prakash.Bl -tag -width Ds 43849cab1c7SVivek Prakash.It Cm N 43949cab1c7SVivek PrakashThe name of the file. 44049cab1c7SVivek Prakash.It Cm R 44149cab1c7SVivek PrakashThe absolute pathname corresponding to the file. 44249cab1c7SVivek Prakash.It Cm T 44349cab1c7SVivek PrakashThe file type, either as in 44449cab1c7SVivek Prakash.Ic ls -F 44549cab1c7SVivek Prakashor in a more descriptive form if the sub field specifier 44649cab1c7SVivek Prakash.Cm H 44749cab1c7SVivek Prakashis given. 44849cab1c7SVivek Prakash.It Cm Y 44949cab1c7SVivek PrakashThe target of a symbolic link. 45049cab1c7SVivek Prakash.It Cm Z 45149cab1c7SVivek PrakashExpands to 452474b24f9SLionel Sambuc.Dq Ar major , Ns Ar minor 45349cab1c7SVivek Prakashfrom the rdev field for character or block 45449cab1c7SVivek Prakashspecial devices and gives size output for all others. 45549cab1c7SVivek Prakash.El 45649cab1c7SVivek Prakash.El 45749cab1c7SVivek Prakash.Pp 45849cab1c7SVivek PrakashOnly the 45949cab1c7SVivek Prakash.Cm % 46049cab1c7SVivek Prakashand the field specifier are required. 46149cab1c7SVivek PrakashMost field specifiers default to 46249cab1c7SVivek Prakash.Cm U 46349cab1c7SVivek Prakashas an output form, with the 46449cab1c7SVivek Prakashexception of 46549cab1c7SVivek Prakash.Cm p 46649cab1c7SVivek Prakashwhich defaults to 46749cab1c7SVivek Prakash.Cm O ; 46849cab1c7SVivek Prakash.Cm a , m , 46949cab1c7SVivek Prakashand 47049cab1c7SVivek Prakash.Cm c 47149cab1c7SVivek Prakashwhich default to 47249cab1c7SVivek Prakash.Cm D ; 47349cab1c7SVivek Prakashand 47449cab1c7SVivek Prakash.Cm Y , T , 47549cab1c7SVivek Prakashand 47649cab1c7SVivek Prakash.Cm N , 47749cab1c7SVivek Prakashwhich default to 47849cab1c7SVivek Prakash.Cm S . 47949cab1c7SVivek Prakash.Sh EXIT STATUS 480*0a6a1f1dSLionel Sambuc.Ex -std 48149cab1c7SVivek Prakash.Sh EXAMPLES 48249cab1c7SVivek PrakashIf no options are specified, the default format is 48349cab1c7SVivek Prakash"%d %i %Sp %l %Su %Sg %r %z \e"%Sa\e" \e"%Sm\e" \e"%Sc\e" \e"%SB\e" %k %b %#Xf %N". 48449cab1c7SVivek Prakash.Bd -literal -offset indent 48549cab1c7SVivek Prakash\*[Gt] stat /tmp/bar 48649cab1c7SVivek Prakash0 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 48749cab1c7SVivek Prakash.Ed 48849cab1c7SVivek Prakash.Pp 489474b24f9SLionel SambucThis example produces output very similar to that from 490474b24f9SLionel Sambuc.Ic find ... -ls 491474b24f9SLionel Sambuc(except that 492474b24f9SLionel Sambuc.Xr find 1 493474b24f9SLionel Sambucdisplays the time in a different format, and 494474b24f9SLionel Sambuc.Xr find 1 495474b24f9SLionel Sambucsometimes adds one or more spaces after the comma in 496474b24f9SLionel Sambuc.Dq Ar major , Ns Ar minor 497474b24f9SLionel Sambucfor device nodes): 498474b24f9SLionel Sambuc.Bd -literal -offset indent 499474b24f9SLionel Sambuc\*[Gt] stat -f "%7i %6b %-11Sp %3l %-17Su %-17Sg %9Z %Sm %N%SY" /tmp/bar 500474b24f9SLionel Sambuc 78852 0 -rw-r--r-- 1 root wheel 0 Jul 8 10:26:03 2004 /tmp/bar 501474b24f9SLionel Sambuc 502474b24f9SLionel Sambuc\*[Gt] find /tmp/bar -ls -exit 503474b24f9SLionel Sambuc 78852 0 -rw-r--r-- 1 root wheel 0 Jul 8 2004 /tmp/bar 504474b24f9SLionel Sambuc.Ed 505474b24f9SLionel Sambuc.Pp 506474b24f9SLionel SambucThis example produces output very similar to that from 507474b24f9SLionel Sambuc.Ic ls -lTd 508474b24f9SLionel Sambuc(except that 509474b24f9SLionel Sambuc.Xr ls 1 510474b24f9SLionel Sambucadjusts the column spacing differently when listing multiple files, 511474b24f9SLionel Sambucand 512474b24f9SLionel Sambuc.Xr ls 1 513474b24f9SLionel Sambucadds at least one space after the comma in 514474b24f9SLionel Sambuc.Dq Ar major , Ns Ar minor 515474b24f9SLionel Sambucfor device nodes): 516474b24f9SLionel Sambuc.Bd -literal -offset indent 517474b24f9SLionel Sambuc\*[Gt] stat -f "%-11Sp %l %Su %Sg %Z %Sm %N%SY" /tmp/bar 518474b24f9SLionel Sambuc-rw-r--r-- 1 root wheel 0 Jul 8 10:26:03 2004 /tmp/bar 519474b24f9SLionel Sambuc 520474b24f9SLionel Sambuc\*[Gt] ls -lTd /tmp/bar 521474b24f9SLionel Sambuc-rw-r--r-- 1 root wheel 0 Jul 8 10:26:03 2004 /tmp/bar 522474b24f9SLionel Sambuc.Ed 523474b24f9SLionel Sambuc.Pp 52449cab1c7SVivek PrakashGiven a symbolic link 52549cab1c7SVivek Prakash.Dq foo 52649cab1c7SVivek Prakashthat points from 52749cab1c7SVivek Prakash.Pa /tmp/foo 52849cab1c7SVivek Prakashto 52949cab1c7SVivek Prakash.Pa / , 53049cab1c7SVivek Prakashyou would use 53149cab1c7SVivek Prakash.Nm 53249cab1c7SVivek Prakashas follows: 53349cab1c7SVivek Prakash.Bd -literal -offset indent 53449cab1c7SVivek Prakash\*[Gt] stat -F /tmp/foo 53549cab1c7SVivek Prakashlrwxrwxrwx 1 jschauma cs 1 Apr 24 16:37:28 2002 /tmp/foo@ -\*[Gt] / 53649cab1c7SVivek Prakash 53749cab1c7SVivek Prakash\*[Gt] stat -LF /tmp/foo 53849cab1c7SVivek Prakashdrwxr-xr-x 16 root wheel 512 Apr 19 10:57:54 2002 /tmp/foo/ 53949cab1c7SVivek Prakash.Ed 54049cab1c7SVivek Prakash.Pp 54149cab1c7SVivek PrakashTo initialize some shell-variables, you could use the 54249cab1c7SVivek Prakash.Fl s 54349cab1c7SVivek Prakashflag as follows: 54449cab1c7SVivek Prakash.Bd -literal -offset indent 54549cab1c7SVivek Prakash\*[Gt] csh 54649cab1c7SVivek Prakash% eval set `stat -s .cshrc` 54749cab1c7SVivek Prakash% echo $st_size $st_mtime 54849cab1c7SVivek Prakash1148 1015432481 54949cab1c7SVivek Prakash 55049cab1c7SVivek Prakash\*[Gt] sh 55149cab1c7SVivek Prakash$ eval $(stat -s .profile) 55249cab1c7SVivek Prakash$ echo $st_size $st_mtime 55349cab1c7SVivek Prakash1148 1015432481 55449cab1c7SVivek Prakash.Ed 55549cab1c7SVivek Prakash.Pp 55649cab1c7SVivek PrakashIn order to get a list of the kind of files including files pointed to if the 55749cab1c7SVivek Prakashfile is a symbolic link, you could use the following format: 55849cab1c7SVivek Prakash.Bd -literal -offset indent 55949cab1c7SVivek Prakash$ stat -f "%N: %HT%SY" /tmp/* 56049cab1c7SVivek Prakash/tmp/bar: Symbolic Link -\*[Gt] /tmp/foo 56149cab1c7SVivek Prakash/tmp/output25568: Regular File 56249cab1c7SVivek Prakash/tmp/blah: Directory 56349cab1c7SVivek Prakash/tmp/foo: Symbolic Link -\*[Gt] / 56449cab1c7SVivek Prakash.Ed 56549cab1c7SVivek Prakash.Pp 56649cab1c7SVivek PrakashIn order to get a list of the devices, their types and the major and minor 56749cab1c7SVivek Prakashdevice numbers, formatted with tabs and linebreaks, you could use the 56849cab1c7SVivek Prakashfollowing format: 56949cab1c7SVivek Prakash.Bd -literal -offset indent 57049cab1c7SVivek Prakashstat -f "Name: %N%n%tType: %HT%n%tMajor: %Hr%n%tMinor: %Lr%n%n" /dev/* 57149cab1c7SVivek Prakash[...] 57249cab1c7SVivek PrakashName: /dev/wt8 57349cab1c7SVivek Prakash Type: Block Device 57449cab1c7SVivek Prakash Major: 3 57549cab1c7SVivek Prakash Minor: 8 57649cab1c7SVivek Prakash 57749cab1c7SVivek PrakashName: /dev/zero 57849cab1c7SVivek Prakash Type: Character Device 57949cab1c7SVivek Prakash Major: 2 58049cab1c7SVivek Prakash Minor: 12 58149cab1c7SVivek Prakash.Ed 58249cab1c7SVivek Prakash.Pp 58349cab1c7SVivek PrakashIn order to determine the permissions set on a file separately, you could use 58449cab1c7SVivek Prakashthe following format: 58549cab1c7SVivek Prakash.Bd -literal -offset indent 58649cab1c7SVivek Prakash\*[Gt] stat -f "%Sp -\*[Gt] owner=%SHp group=%SMp other=%SLp" . 58749cab1c7SVivek Prakashdrwxr-xr-x -\*[Gt] owner=rwx group=r-x other=r-x 58849cab1c7SVivek Prakash.Ed 58949cab1c7SVivek Prakash.Pp 59049cab1c7SVivek PrakashIn order to determine the three files that have been modified most recently, 59149cab1c7SVivek Prakashyou could use the following format: 59249cab1c7SVivek Prakash.Bd -literal -offset indent 59349cab1c7SVivek Prakash\*[Gt] stat -f "%m%t%Sm %N" /tmp/* | sort -rn | head -3 | cut -f2- 59449cab1c7SVivek PrakashApr 25 11:47:00 2002 /tmp/blah 59549cab1c7SVivek PrakashApr 25 10:36:34 2002 /tmp/bar 59649cab1c7SVivek PrakashApr 24 16:47:35 2002 /tmp/foo 59749cab1c7SVivek Prakash.Ed 598474b24f9SLionel Sambuc.Pp 599474b24f9SLionel SambucUser names, group names, and file names that contain spaces 600474b24f9SLionel Sambucor other special characters may be encoded in 601474b24f9SLionel Sambuc.Xr vis 3 602474b24f9SLionel Sambucstyle, using the 603474b24f9SLionel Sambuc.Cm \&# 604474b24f9SLionel Sambucmodifier: 605474b24f9SLionel Sambuc.Bd -literal -offset indent 606474b24f9SLionel Sambuc\*[Gt] ln -s 'target with spaces' 'link with spaces' 607474b24f9SLionel Sambuc\*[Gt] stat -f "%#N%#SY" 'link with spaces' 608474b24f9SLionel Sambuclink\eswith\esspaces -\*[Gt] target\eswith\esspaces 609474b24f9SLionel Sambuc.Ed 61049cab1c7SVivek Prakash.Sh SEE ALSO 61149cab1c7SVivek Prakash.Xr basename 1 , 61249cab1c7SVivek Prakash.Xr dirname 1 , 61349cab1c7SVivek Prakash.Xr file 1 , 61449cab1c7SVivek Prakash.Xr ls 1 , 61549cab1c7SVivek Prakash.Xr lstat 2 , 61649cab1c7SVivek Prakash.Xr readlink 2 , 61749cab1c7SVivek Prakash.Xr stat 2 , 61849cab1c7SVivek Prakash.Xr printf 3 , 61949cab1c7SVivek Prakash.Xr strftime 3 62049cab1c7SVivek Prakash.Sh HISTORY 62149cab1c7SVivek PrakashThe 62249cab1c7SVivek Prakash.Nm 62349cab1c7SVivek Prakashutility appeared in 62449cab1c7SVivek Prakash.Nx 1.6 . 62549cab1c7SVivek Prakash.Sh AUTHORS 62649cab1c7SVivek Prakash.An -nosplit 62749cab1c7SVivek PrakashThe 62849cab1c7SVivek Prakash.Nm 62949cab1c7SVivek Prakashutility was written by 63049cab1c7SVivek Prakash.An Andrew Brown 63149cab1c7SVivek Prakash.Aq atatat@NetBSD.org . 63249cab1c7SVivek PrakashThis man page was written by 63349cab1c7SVivek Prakash.An Jan Schaumann 63449cab1c7SVivek Prakash.Aq jschauma@NetBSD.org . 635