Came across a more complicate scenario on top the previous post by looping two layers:
for I in 1{01..32} 20{0..9}
do
for J in A1 A2 B1 B2
mkdir -p DES_P${I}${J}
cp SRC_P${I}${J} DES_P{I}${J}
# cp ${!SRC_P${I}${J}} ${!DES_P{I}${J}} # Did not work: -Bash: ${!SRC_P${I}${J}}: bad substitution
done
done
There are 168 folders. All the SRC_P${I}${J} were manually collected and defined from different folders (irregular, not even easy to do by regex) like:
How to loop through the two layers and make the destination folders organized nicer and for easier peek-into in the future? Or am I thinking the wrong way? Thanks!
echo cp "SRC_${!I}" "DES_${!I}" but SRC_${!I} did not expand as wanted.
Must remember this way! assembles new variable names first, so their bare names can be used!
Thanks a lot!