-
-
Save Nill-R/27079d487adfc002c46df1e7bf835002 to your computer and use it in GitHub Desktop.
Command-line Lorem Ipsum generator using curl, lipsum.com, and jq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
AMOUNT=10 | |
WHAT=paras | |
START=true | |
while getopts ":n:wpbls" opt; do | |
case $opt in | |
n) | |
AMOUNT=$OPTARG | |
;; | |
w) | |
WHAT=words | |
;; | |
p) | |
WHAT=paras | |
;; | |
b) | |
WHAT=bytes | |
;; | |
l) | |
WHAT=lines | |
;; | |
s) | |
START=true | |
;; | |
*) | |
echo "Invalid option: -$OPTARG" >&2 | |
;; | |
esac | |
done | |
curl -s -X POST https://lipsum.com/feed/json -d "amount=$AMOUNT" -d "what=$WHAT" -d"start=$START" | jq -r '.feed.lipsum' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment