As I couldn't use:
curl https://dev.to/api/articles/ | grep -oP '(?<=\"id\"\:)\d+' | head -n 1
as -P doesn't work in macOS I replaced it with the utility I use to pretty print JSON, jq:
-P
jq
> curl https://dev.to/api/articles | jq '.[0].id' 266498
or even better, as we don't need the entire page:
> total=$(curl "https://dev.to/api/articles?per_page=1" | jq '.[0].id') > echo $total 266498
this doesn't work in macOS either:
curl https://dev.to/api/articles/246755 | sed -r 's/.*created_at\"\:\".{11}(..).*/\1/'
I replaced it with:
> curl https://dev.to/api/articles/246755 | jq '.created_at' | sed 's/^.*T\(.*\)\:.*\:.*/\1/' 20
or even better:
> curl https://dev.to/api/articles/246755 | jq '.created_at[11:13]' | sed 's/"//g' 20
jq is truly awesome :D stedolan.github.io/jq/manual/
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
As I couldn't use:
as
-P
doesn't work in macOS I replaced it with the utility I use to pretty print JSON,jq
:or even better, as we don't need the entire page:
this doesn't work in macOS either:
I replaced it with:
or even better:
jq is truly awesome :D stedolan.github.io/jq/manual/