Skip to content

Instantly share code, notes, and snippets.

@loisaidasam
Last active May 24, 2017 04:31
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 loisaidasam/e19c144936b9a398a44eea25fb2e11ad to your computer and use it in GitHub Desktop.
Save loisaidasam/e19c144936b9a398a44eea25fb2e11ad to your computer and use it in GitHub Desktop.
Get the basename for a URL or path file
#!/bin/bash
# Turn a URL or path like this:
#
# "https://lastfm-img2.akamaized.net/i/u/300x300/daa535a86371482ec8fd7f3451114367.png"
#
# into this:
#
# "daa535a86371482ec8fd7f3451114367.png"
function get_basename () {
echo "$1" | rev | cut -d / -f 1 | rev
}
@loisaidasam
Copy link
Author

Just found out this is already a thing:

basename "$1"

...

http://www.clker.com/cliparts/4/0/8/f/1310565736166702798doh-md.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment