Created
July 6, 2020 06:40
-
-
Save shaybensasson/6443becf5fe22ad35aeb9cb48e9ff805 to your computer and use it in GitHub Desktop.
bash script that extract filename and extension from a parameter
This file contains hidden or 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 | |
| set -e | |
| # Any subsequent(*) commands which fail will cause the shell script to exit immediately | |
| input=$1 | |
| #filename=$(basename -- "$fullfile") | |
| #extension="${filename##*.}" | |
| #filename="${filename%.*}" | |
| filename="${input%%.*}" | |
| extension="${input#*.}" | |
| echo $filename | |
| echo $extension |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment