How to do it...

The % operator will extract the name from name.extension. This example extracts sample from sample.jpg:

file_jpg="sample.jpg" 
name=${file_jpg%.*} 
echo File name is: $name 

The output is this:

File name is: sample

The # operator will extract the extension:

Extract .jpg from the filename stored in the file_jpg variable:

extension=${file_jpg#*.} 
echo Extension is: jpg 

The output is as follows:

Extension is: jpg