I have some folders:oldA with A_1.aaa, A_2.aaa, A_1.bbb, A.def, A.ghi oldB with B_1.aaa, B_2.aaa, B_1.bbb, B.def, B.ghiand so onand need to copy them to another folder with selection.I want only A.def and A.ghi copy to /newA, so do with B. I have written a script but it doesn't work.for i in A B C Ddo  folder=new${i}  mkdir $folder;  cp path/to/old${i}/${i}{.def,.ghi} $folder  cd $folder; some commands  cd ..doneThe error is cp: cannot stat oldA/A{.def,.ghi}: No such file or directoryHowever, when I use direct command cp path/to/oldA/A{.def,.ghi} newA, it works well. What should I do? If I want to copy only A_1.aaa and A_2.aaa, will the procedure be similar?This is my actually script.#!/bin/bashfolder=Dispersemkdir $foldercp 3B7V.pdb $foldercd $folder#awk '$5 != C' 3B7V.pdb > 3B7V_temp.pdb#awk '$4 != C' 3B7V_temp.pdb > AB.pdbsed -n 403,1981p 3B7V.pdb > A.pdbsed -n 1982,3586p 3B7V.pdb > B.pdbcd ..;mkdir EM;cd EMfor i in A Bdo   folder=${i}_EM  mkdir $folder  cp ../em.mdp ../Disperse/${i}.pdb $folder  cd $folder  echo -e \n4 | pdb2gmx -f ${i}.pdb -o ${i}.gro -water none  grompp -f em.mdp -c ${i}.gro -p topol.top -o ${i}_em.tpr  mdrun -v -deffnm ${i}_em  #grompp -f em.mdp -c ${i}_em.gro -p topol.top -o ${i}_em_mead.tpr  cd .. #at EM folderdonecd ..;mkdir PQR;cd PQRfor i in A Bdo  folder=${i}_PQR  mkdir $folder  cp ../EM/${i}_EM/${i}* $folder  cd $folder  editconf -f ${i}_em.gro -o ${i}_em.pdb  awk '$1 != REMARK' ${i}_em.pdb > ${i}_temp.pdb  pdb2pqr --ff=AMBER --apbs-input ${i}_temp.pdb ${i}.pqr -v > log_${i}  #editconf -f ${i}_em_mead.tpr -mead ${i}_gro.pqr  #for j in *.pqr; do sed 1,8d $j > ../${j/.*}_sed.pqr; done  cd .. #at PQR folderdonecd ..;mkdir APBS;cd APBSfor i in A Bdo  folder=${i}_APBS  mkdir $folder;ls  cp ../PQR/${i}_PQR/${i}{.pqr,.in} $folder  cd $folder  abps ${i}.in  cd .. #at APBS folderdoneAlso, I have another problem in Konsole. I don't know whether it is relevant or not but I will post here too.
Copy selected files had subtitutions in name
cp;variable substitution
It turns out that I use $ sh script to run the scrip, not $ bash script.The brace expansion requires bash to run.