linux substring code example
Example 1: bash print substring of a field
awk 'BEGIN {FS="input_delimiter"; OFS="output_delimiter"} {print substr($column_number, start_character, number_characters)}' input_file
customer info ID:123456 account
customer info ID:172327 account
awk 'BEGIN {FS="\t"; OFS="\t"} {print substr($3, 4, 6)}' input_file
123456
172327
Example 2: substring in shell script
STR="birthday-091216-pics"
SUBSTR=$(echo $STR | cut -d'-' -f 2)
echo $SUBSTR
Example 3: how to print substring in bash script
INPUT='someletters_12345_moreleters.ext'
SUBSTRING=$(echo $INPUT| cut -d'_' -f 2)
echo $SUBSTRING