1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add List Stats For A File as a unix til

This commit is contained in:
jbranchaud
2018-07-14 14:58:23 -05:00
parent 2006b49e26
commit 7c622f5f57
2 changed files with 30 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
For a steady stream of TILs from a variety of rocketeers, checkout
[til.hashrocket.com](https://til.hashrocket.com/).
_688 TILs and counting..._
_689 TILs and counting..._
---
@@ -642,6 +642,7 @@ _688 TILs and counting..._
- [List Names Of Files With Matches](unix/list-names-of-files-with-matches.md)
- [List Of Sessions To A Machine](unix/list-of-sessions-to-a-machine.md)
- [List Parent pid With ps](unix/list-parent-pid-with-ps.md)
- [List Stats For A File](unix/list-stats-for-a-file.md)
- [List The Available JDKs](unix/list-the-available-jdks.md)
- [Map A Domain To localhost](unix/map-a-domain-to-localhost.md)
- [Only Show The Matches](unix/only-show-the-matches.md)

View File

@@ -0,0 +1,28 @@
# List Stats For A File
The `ls` command is good for listing files. Tacking on the `-la` flags gives
you a bunch of info about each of the listed files. To get even more info,
we can use the `stat` command.
```bash
$ stat README.md
16777220 143994676 -rw-r--r-- 1 jbranchaud staff 0 53557 "Jul 14 14:53:44 2018" "Jul 10 14:54:39 2018" "Jul 10 14:54:39 2018" "Jul 10 14:54:39 2018" 4096 112 0 README.md
```
That's definitely more info, but it is unlabeled and a lot to parse. We can
improve the output with the `-x` flag.
```bash
$ stat -x README.md
File: "README.md"
Size: 53557 FileType: Regular File
Mode: (0644/-rw-r--r--) Uid: ( 501/jbranchaud) Gid: ( 20/ staff)
Device: 1,4 Inode: 143994676 Links: 1
Access: Sat Jul 14 14:53:44 2018
Modify: Tue Jul 10 14:54:39 2018
Change: Tue Jul 10 14:54:39 2018
```
See `man stat` for more details.
[source](https://www.unixtutorial.org/2008/11/how-to-update-atime-and-mtime-for-a-file-in-unix/)