Last active
May 24, 2017 04:31
-
-
Save loisaidasam/e19c144936b9a398a44eea25fb2e11ad to your computer and use it in GitHub Desktop.
Get the basename for a URL or path file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just found out this is already a thing:
basename "$1"
...