Skip to content

Instantly share code, notes, and snippets.

@hemanth22
Forked from candu/lipsum
Created May 7, 2021 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hemanth22/c19aac86fb28d7e06b90b22646aadd92 to your computer and use it in GitHub Desktop.
Save hemanth22/c19aac86fb28d7e06b90b22646aadd92 to your computer and use it in GitHub Desktop.
Command-line Lorem Ipsum generator using curl, lipsum.com, and jq
#!/bin/sh
AMOUNT=5
WHAT=paras
START=false
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 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