diff --git a/README.md b/README.md index f2af2c3..46c1fa5 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/unix/list-stats-for-a-file.md b/unix/list-stats-for-a-file.md new file mode 100644 index 0000000..4ddd1da --- /dev/null +++ b/unix/list-stats-for-a-file.md @@ -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/)