linux get part of string code example
Example 1: linux get part of string
number=$(echo $filename | egrep -o '[[:digit:]]{5}' | head -n1)
Example 2: linux get part of string
b=${a:12:5}
Example 3: linux get part of string
INPUT='someletters_12345_moreleters.ext'
SUBSTRING=$(echo $INPUT| cut -d'_' -f 2)
echo $SUBSTRING