I trying to get the details of files inside several folders and add it to a file called aa.txt, but the content is overwritten when go to different folder.
How can I add it to the file without overwriting the previous content?
for folder in R1 R2 R3 R4 P1 P2 P3 P4 M1 M2 M3 M4 S1 S2 S3 S4
do
cd $folder
# run folowing commands in the folder
ls -ltr | cat > ../aa.txt
echo " $folder done" >> ../Completed.text
cd ..
done