Skip to content

Instantly share code, notes, and snippets.

@shaybensasson
Created July 6, 2020 06:40
Show Gist options
  • Select an option

  • Save shaybensasson/6443becf5fe22ad35aeb9cb48e9ff805 to your computer and use it in GitHub Desktop.

Select an option

Save shaybensasson/6443becf5fe22ad35aeb9cb48e9ff805 to your computer and use it in GitHub Desktop.
bash script that extract filename and extension from a parameter
#!/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