FileContent=$(awk '{print $0}' largeFile2) # this is where I think I have a problem : # LINE contains start and offset identifying each record in largeFile2 while read LINE;do pass=1 for results in $LINE; do if [[ $pass -eq 1 ]];then from=$results pass=2 else to=$results fi done (( from=$val1+1 )) (( to=$val1+$val2 )) newOut=$(echo $FileContent|cut -c $from-$to) echo $newOut >> newfile done < indexFile1