#Bash #Shell #Scripting for #beginners (Part 1) - #Fedora Magazine
https://fedoramagazine.org/bash-shell-scripting-for-beginners-part-1/
5 Likes
https://fedoramagazine.org/bash-shell-scripting-for-beginners-part-1/
I've needed to do this often enough, and gotten it wrong sufficiently many times, that I've finally written a simple shell script using jq
and sed
, to return straight Markdown from a Diaspora post. It mostly makes re-editing typos easier.
#!/bin/sh
jq -M .text | sed 's/^"//; s/"$//; s/\\r\\n/\n/g; s/\\"/"/g'
Saved as unjsonify-diaspora
.
This extracts the '.text' element, trims leading and trailing quotes, replaces \r\n
sequences with linefeeds, and unescapes quotes. Some further substitutions may be required though so far it seems good.
"But how do you get the JSON" you ask? Simple: append .json
to any Diaspora URL.
For example: https://joindiaspora.com/posts/c7415d50e97f01385366002590d8e506
Becomes: https://joindiaspora.com/posts/c7415d50e97f01385366002590d8e506.json
You can either copy/paste the rendered content to the script, or (preferable) use a web uttility such as curl
or wget
to pipe directly to the script:
curl --silent https://joindiaspora.com/posts/c7415d50e97f01385366002590d8e506.json |
unjsonify-diaspora
Usually I'm doing this to fix typos, so you could send this on to an editor:
curl --silent <url> | unjsonify-diaspora | vim -
Then delete your old, buggy post and replace it with a new buggy one.
#json #jq #ShellScripts #JustLinuxThings #linux #diaspoa #tips
Following the YouTube Anschluss in which Google forcibly integrated G+ and YouTube accounts (among other properties), against my express wishes, pretty much forever violating my trust in the company, I made the conscious decision to largely exit G+, removing my content, while archiving what I'd previously posted.
Pulling useful information out of those archives has been ... interesting.
Continued at the dreddit
#googleplustips #archives #json #pandoc #shellscripts #linuxhacks