From 89dc799bacc93b0c1d20494e62dc9ab179379c2d Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 27 Mar 2019 14:48:41 -0500 Subject: [PATCH] Add Print A Range Of Lines For A File With Bat as a unix til --- README.md | 3 ++- ...nt-a-range-of-lines-for-a-file-with-bat.md | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 unix/print-a-range-of-lines-for-a-file-with-bat.md diff --git a/README.md b/README.md index c9d72b5..481f42e 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/). -_797 TILs and counting..._ +_798 TILs and counting..._ --- @@ -739,6 +739,7 @@ _797 TILs and counting..._ - [Open The Current Command In An Editor](unix/open-the-current-command-in-an-editor.md) - [Partial String Matching In Bash Scripts](unix/partial-string-matching-in-bash-scripts.md) - [PID Of The Current Shell](unix/pid-of-the-current-shell.md) +- [Print A Range Of Lines For A File With Bat](unix/print-a-range-of-lines-for-a-file-with-bat.md) - [Repeat Yourself](unix/repeat-yourself.md) - [Saying Yes](unix/saying-yes.md) - [Search Files Specific To A Language](unix/search-files-specific-to-a-language.md) diff --git a/unix/print-a-range-of-lines-for-a-file-with-bat.md b/unix/print-a-range-of-lines-for-a-file-with-bat.md new file mode 100644 index 0000000..8d237b3 --- /dev/null +++ b/unix/print-a-range-of-lines-for-a-file-with-bat.md @@ -0,0 +1,19 @@ +# Print A Range Of Lines For A File With Bat + +I recently learned about a [faster and more colorful alternative to +cat](https://chireviewofbooks.com/2018/12/11/here-are-the-winners-of-the-2018-chicago-review-of-books-awards/) +-- [`bat`](https://github.com/sharkdp/bat). Like `cat`, the standard usage +is to print the entire contents of a file. You can instruct `bat` to only +print a range of lines from a file using the `--line-range` flag. + +For instance the following command + +```bash +$ bat --line-range=918:925 README.md +``` + +will produce the following output + +![a range of lines from the README](https://i.imgur.com/MmKbNvl.png) + +See `man bat` for more details.