Skip to content

Instantly share code, notes, and snippets.

@Leask
Created September 5, 2013 14:02
Show Gist options
  • Select an option

  • Save Leask/6450497 to your computer and use it in GitHub Desktop.

Select an option

Save Leask/6450497 to your computer and use it in GitHub Desktop.
Parse YouTube url (get youtube video id)
sh -c 'url="http://youtu.be/MejbOFk7H6c"; vid="`for i in ".*youtu\.be/\([^\/&?#]\+\)" ".*youtu.\+v[=/]\([^\/&?#]\+\)" ".*youtu.\+embed/\([^\/&?#]\+\)"; do expr "${url}" : "${i}"; done`"; if [ -n "${vid}" ]; then echo ${vid}; else echo "${url}"; fi'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment