for n in 000{0..999}; do
M=${n#???} N=${n##${n%???}}
[ -f "${M}_nc.fasta" ] && sed -e "s/^>/&$N-/" < "${M}_nc.fasta" > "${N}_tagged.fasta"
done
#Summary n varies from 0000 -> 000999 M varies from 0 -> 999 strip off the first 3 chars ${n#???} N is computed by removing the last 3 chars from n then what remains is then stripped , essentially performing the act of padding to 3 digits.
compute the filenames:
fasda filename = ${M}_nc.fasta <------ input file to sed
new filename = ${N}_tagged.fasta <---- output file from sed
sed command: "s/^>/&$N-/"