From c1ce5594525af55a3c7dea328265772b87285699 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Sun, 16 Nov 2025 22:21:45 -0600 Subject: [PATCH] Add Add A Bunch Of CLI Utilities With corutils as a Mac TIL --- README.md | 3 +- ...a-bunch-of-cli-utilities-with-coreutils.md | 51 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 mac/add-a-bunch-of-cli-utilities-with-coreutils.md diff --git a/README.md b/README.md index 359501b..c6f9e8c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1692 TILs and counting..._ +_1693 TILs and counting..._ See some of the other learning resources I work on: @@ -699,6 +699,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Access All Screen And Video Capture Options](mac/access-all-screen-and-video-capture-options.md) - [Access System Information On OS X](mac/access-system-information-on-osx.md) - [Access Unsupported Screen Resolutions With RDM](mac/access-unsupported-screen-resolutions-with-rdm.md) +- [Add A Bunch Of CLI Utilities With coreutils](mac/add-a-bunch-of-cli-utilities-with-coreutils.md) - [Capture Screenshot To Clipboard From CLI](mac/capture-screenshot-to-clipboard-from-cli.md) - [Check Network Quality Stats From The Command Line](mac/check-network-quality-stats-from-the-command-line.md) - [Clean Up Old Homebrew Files](mac/clean-up-old-homebrew-files.md) diff --git a/mac/add-a-bunch-of-cli-utilities-with-coreutils.md b/mac/add-a-bunch-of-cli-utilities-with-coreutils.md new file mode 100644 index 0000000..5b8b869 --- /dev/null +++ b/mac/add-a-bunch-of-cli-utilities-with-coreutils.md @@ -0,0 +1,51 @@ +# Add A Bunch Of CLI Utilities With coreutils + +The [`coreutils`](https://www.gnu.org/software/coreutils/) project is a +collection of useful utilities that every operating system ought to have. + +> The GNU Core Utilities are the basic file, shell and text manipulation +> utilities of the GNU operating system. These are the core utilities which are +> expected to exist on every operating system. + +While many of these utilities are redundant with BSD utilities that MacOS +chooses to ship with, there are some differences in the overlapping ons and then +many additions from `coreutils`. + +They can be installed with Homebrew: + +```bash +$ brew install coreutils +``` + +And then you should have some new things available on your path. Take `shuf`, for +instance. This utility can shuffle and select items from a file or incoming +lines from another command. Here I use it to randomly grab a number between 1 +and 5 (with the help of `seq`): + +```bash +❯ seq 1 5 | shuf -n 1 +3 + +❯ seq 1 5 | shuf -n 1 +2 + +❯ seq 1 5 | shuf -n 1 +5 +``` + +Or how about some utilities for manipulating file names? Among others there is +`realpath`, `basename`, and `dirname`. + +```bash +❯ realpath README.md +/Users/lastword/dev/jbranchaud/til/README.md + +❯ realpath README.md | xargs basename +README.md + +❯ realpath README.md | xargs dirname +/Users/lastword/dev/jbranchaud/til +``` + +See the [manual](https://www.gnu.org/software/coreutils/manual/coreutils.html) +for many more details.