Shell Script to Get Last Character of a String May 4th, 2014 There are a couple of ways to extract the last character of a string within a shell script. The easiest way is if you are working on bash shell – as bash will get the job done without the help of any external utilities.