#!/bin/bash FILE_PATH="./words.txt" while read -r line; do for (( i=0; i<${#line}; i++ )); do printf "%d-" "'${line:$i:1}" done done < "$FILE_PATH"