mirror of
https://github.com/jbranchaud/til
synced 2026-01-02 22:58:01 +00:00
Add Add A Bunch Of CLI Utilities With corutils as a Mac TIL
This commit is contained in:
@@ -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)
|
||||
|
||||
51
mac/add-a-bunch-of-cli-utilities-with-coreutils.md
Normal file
51
mac/add-a-bunch-of-cli-utilities-with-coreutils.md
Normal file
@@ -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.
|
||||
Reference in New Issue
Block a user