I need to write a script (in bash) that copies the content of the first file in each folder of a directory to the second file in the same folder. I tried this and it didn't work - it just came back with errors and I'm not sure how to fix it. Help is very much appreciated!
for mpdir in ${PWD}/000*/*[Aa]*; do
firstmat=`ls ${mpdir}/*.mat|head -1`;
cp ${firstmat} tmp;
for f in ${mpdir}/*.mat; do cp tmp ${f}; done;
rm tmp; \
done