Skip to content

Instantly share code, notes, and snippets.

@electron0zero
Last active February 15, 2020 21:27
Show Gist options
  • Save electron0zero/3836953b8c87d90ff686a3c28870ca7b to your computer and use it in GitHub Desktop.
Save electron0zero/3836953b8c87d90ff686a3c28870ca7b to your computer and use it in GitHub Desktop.
URL to Markdown link with title - bash
# bash script to get title of a url and then dump it in Markdown format link
# credit: https://unix.stackexchange.com/a/103253
function url_to_md( ) {
t=$(wget -qO- $1 | perl -l -0777 -ne 'print $1 if /<title.*?>\s*(.*?)\s*<\/title/si')
echo "[$t]($1)"
}
# example usage
~/wd $ url_to_md https://kubernetes.io/docs/tasks/debug-application-cluster/debug-init-containers/
[Debug Init Containers - Kubernetes](https://kubernetes.io/docs/tasks/debug-application-cluster/debug-init-containers/)
~/wd $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment