File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010
1111For a steady stream of TILs, [ sign up for my newsletter] ( https://crafty-builder-6996.ck.page/e169c61186 ) .
1212
13- _ 1337 TILs and counting..._
13+ _ 1338 TILs and counting..._
1414
1515---
1616
@@ -1318,6 +1318,7 @@ _1337 TILs and counting..._
13181318- [ Occupy A Local Port With Netcat] ( unix/occupy-a-local-port-with-netcat.md )
13191319- [ Only Show The Matches] ( unix/only-show-the-matches.md )
13201320- [ Open The Current Command In An Editor] ( unix/open-the-current-command-in-an-editor.md )
1321+ - [ Output The Last N Bytes Of A Large File] ( unix/output-the-last-n-bytes-of-a-large-file.md )
13211322- [ Partial String Matching In Bash Scripts] ( unix/partial-string-matching-in-bash-scripts.md )
13221323- [ PID Of The Current Shell] ( unix/pid-of-the-current-shell.md )
13231324- [ Print A Range Of Lines For A File With Bat] ( unix/print-a-range-of-lines-for-a-file-with-bat.md )
Original file line number Diff line number Diff line change 1+ # Output The Last N Bytes Of A Large File
2+
3+ After creating a massive JSON file as part of a data export, I wanted to check
4+ the timestamp of the last value in the file. However, even for Vim, the file
5+ was big and it was taking a while to bring the whole thing into memory.
6+
7+ I didn't really need to open it in a full-fledged editor, I just needed to grab
8+ the trailing bits (bytes!) of the file until I could see enough data to verify
9+ the export.
10+
11+ The ` tail ` command is a great tool for this because it can quickly read
12+ information from the end of a file. The ` -c ` flag in particular allows you to
13+ grab the last N bytes of the file and output them.
14+
15+ So, I started with:
16+
17+ ``` bash
18+ $ tail -c 100 data.json
19+ ```
20+
21+ That didn't quite show me enough info, so I bumped it up:
22+
23+ ``` bash
24+ $ tail -c 1000 data.json
25+ ```
26+
27+ That time I was able to see enough to verify the export.
28+
29+ Both commands ran instantaneously, meanwhile my editor was still opening the
30+ file.
31+
32+ See ` man tail ` for more details.
You can’t perform that action at this time.
0 commit comments