我有一些文件夹:
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.ghi
and so on
并需要将它们复制到另一个文件夹并进行选择。
我只想将 A.def 和 A.ghi 复制到 /newA,B 也是如此。我已经编写了一个脚本,但它不起作用。
for i in A B C D
do
folder="new${i}"
mkdir $folder;
cp path/to/old${i}/${i}{.def,.ghi} $folder
cd $folder; some commands
cd ..
done
错误是cp: cannot stat ‘oldA/A{.def,.ghi}’: No such file or directory
但是,当我使用直接命令时cp path/to/oldA/A{.def,.ghi} newA
,效果很好。我应该怎么办?
如果我只想复制A_1.aaa和A_2.aaa,过程会类似吗?
这实际上是我的脚本。
#!/bin/bash
folder="Disperse"
mkdir $folder
cp 3B7V.pdb $folder
cd $folder
#awk '$5 != "C"' 3B7V.pdb > 3B7V_temp.pdb
#awk '$4 != "C"' 3B7V_temp.pdb > AB.pdb
sed -n 403,1981p 3B7V.pdb > A.pdb
sed -n 1982,3586p 3B7V.pdb > B.pdb
cd ..;mkdir EM;cd EM
for i in A B
do
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 folder
done
cd ..;mkdir PQR;cd PQR
for i in A B
do
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 folder
done
cd ..;mkdir APBS;cd APBS
for i in A B
do
folder="${i}_APBS"
mkdir $folder;ls
cp ../PQR/${i}_PQR/${i}{.pqr,.in} $folder
cd $folder
abps ${i}.in
cd .. #at APBS folder
done
另外,我还有一个问题在康索莱。我不知道它是否相关,但我也会在这里发布。
答案1
事实证明,我用来$ sh script
运行脚本,而不是$ bash script
。这大括号扩展需要 bash 才能运行。