If you want to use loop anyhow to execute your output as you desire. I suggest you can use it as
for file in "$(cd dir1 | find . -type f)"
do
cp $file dir3
echo $file
done
This will only copy your files from dir1 to dir3 and will ignore the subdirectories from getting copied in dir3.
But, if you want to copy the subdirectories as well then use the loop as
for file in "$(cd dir1 | ls)"
do
cp $file dir3
echo $file
done
And this will work f9.
|