Skip to content

Commit 7c622f5

Browse files
committed
Add List Stats For A File as a unix til
1 parent 2006b49 commit 7c622f5

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
1010
For a steady stream of TILs from a variety of rocketeers, checkout
1111
[til.hashrocket.com](https://til.hashrocket.com/).
1212

13-
_688 TILs and counting..._
13+
_689 TILs and counting..._
1414

1515
---
1616

@@ -642,6 +642,7 @@ _688 TILs and counting..._
642642
- [List Names Of Files With Matches](unix/list-names-of-files-with-matches.md)
643643
- [List Of Sessions To A Machine](unix/list-of-sessions-to-a-machine.md)
644644
- [List Parent pid With ps](unix/list-parent-pid-with-ps.md)
645+
- [List Stats For A File](unix/list-stats-for-a-file.md)
645646
- [List The Available JDKs](unix/list-the-available-jdks.md)
646647
- [Map A Domain To localhost](unix/map-a-domain-to-localhost.md)
647648
- [Only Show The Matches](unix/only-show-the-matches.md)

unix/list-stats-for-a-file.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# List Stats For A File
2+
3+
The `ls` command is good for listing files. Tacking on the `-la` flags gives
4+
you a bunch of info about each of the listed files. To get even more info,
5+
we can use the `stat` command.
6+
7+
```bash
8+
$ stat README.md
9+
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
10+
```
11+
12+
That's definitely more info, but it is unlabeled and a lot to parse. We can
13+
improve the output with the `-x` flag.
14+
15+
```bash
16+
$ stat -x README.md
17+
File: "README.md"
18+
Size: 53557 FileType: Regular File
19+
Mode: (0644/-rw-r--r--) Uid: ( 501/jbranchaud) Gid: ( 20/ staff)
20+
Device: 1,4 Inode: 143994676 Links: 1
21+
Access: Sat Jul 14 14:53:44 2018
22+
Modify: Tue Jul 10 14:54:39 2018
23+
Change: Tue Jul 10 14:54:39 2018
24+
```
25+
26+
See `man stat` for more details.
27+
28+
[source](https://www.unixtutorial.org/2008/11/how-to-update-atime-and-mtime-for-a-file-in-unix/)

0 commit comments

Comments
 (0)