stat command in UNIX
stat [OPTION]... FILE...Introduction
Section titled “Introduction”stat command displays file or file system status.
Options
Section titled “Options”Here are some of the options that you will use the most:
-L,--dereference: follow links-f,--file-system: display file system status instead of file status-c --format=FORMAT: use the specifiedFORMATinstead of the default.
output a newline after each use ofFORMAT--printf=FORMAT: interpret backslash escapes, and do not output a mandatory trailing newline.
if you want a newline, include\ninFORMAT-t,--terse: print the information in terse form
The valid format sequences for files (without --file-system) are so many that I suggest you to look for the official documentation to see them all.
Examples
Section titled “Examples”Without any parameters, stat command displays the default output: file size and type, device type, inode number, UID, GID, number of links and access/modification dates of the file.
stat my-file.txt File: my-file.txt Size: 26 Blocks: 8 IO Block: 4096 regular fileDevice: 10302h/66306d Inode: 15208760 Links: 1Access: (0664/-rw-rw-r--) Uid: ( 1000/ pit) Gid: ( 1000/ pit)Access: 2022-06-02 12:21:00.264595989 +0200Modify: 2021-11-28 12:54:55.057498677 +0100Change: 2022-01-30 00:10:19.688493688 +0100 Birth: -Check the filesystem status by using the -f option as shown below:
stat --file-system Documents/ File: "Documents/" ID: 37eab0e240a4b3a1 Namelen: 255 Type: ext2/ext3Block size: 4096 Fundamental block size: 4096Blocks: Total: 122672878 Free: 70186800 Available: 63937930Inodes: Total: 31227904 Free: 28939751To only display inode and UID of a file, you need to use %i and %u format sequences inside FORMAT string for --printf option.
Please Note: \t print a tab (8 spaces) and \n print a new line.
stat --printf='%i\t%u\n' wifi-pwd.txt15208760 1000Quotes
Section titled “Quotes”Manual reference: