Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

commented May 24, 2017

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
You can’t perform that action at this time.