#!/bin/zsh for i in 0 1 2 3 4 5 6 7 8 do for file in `ls cd$i*` do ktutil << EOF read_kt $file done write_kt /tmp/krb5.keytab.cd$i EOF done