#!/bin/sh dir="$1" rm $dir/* source functions.sh while read -r line; do fl=$(firstLetter "$line") ll=$(lastLetter "$line") echo "$line" >> "$dir/$fl$ll" done