I am already doing a for loop inside all my directories starting with abcd and it is working. But when I have other files or stuff in the root directory, it crashes after the first loop.
dir_1="./some/path1"
dir_2="./some/path2"
dir_3="./some/path3"
for f in ./abcd*;
do
[ -d $f ] && cd "$f" && echo I am inside $f
find $dir_1 -name something*.txt -exec cp {} $dir_3 \;
find $dir_2 -name another*.txt -exec cp {} $dir_3 \;
cd "$dir_3"
# do some other stuff here
cd ../../..
done;
could somebody help me repair it?