#!/usr/bin/env bash s="abcdefgh" # ${var:offset:length} extracts a substring echo "${s:2:3}" # a negative offset (note the space) counts from the end echo "${s: -2}"
${s:offset:length} slices a string