Get A Random Line From A Text File On The Mac Command Line
I'm working on a little command to display a random quote every time I open a new terminal window. I setup a file with a bunch of quotes. Each one is on its own line.
To pull a random quote/line, I'm using :
|
### Details
- The [TODO: Code shorthand span ] creates a randomized set of lines from the file - Then [TODO: Code shorthand span ] cuts it down to just the first line. It works great
### Notes :
- Lots of notes on the web say to use ` shuf - n 1 ` , but that's not installed by default on my machine running macOS 12.x Monterey. - The [TODO: Code shorthand span ] and [TODO: Code shorthand span ] commands were available on my machine without having to install anything. That said, it's possible that something else that I installed with homebrew also installed them. Your milage may vary.