how can i copy those files into other directories have the same name but different in the end
i have files in directory called test:
10_10_asdadfsdfad.txt
10_10_11_asdawqefwkjasd.txt
10_10_11_12_asdafjjhoqwd.txt
i want to put them in exist directory thart i have on my system
i have directories in directory called test2:
10_10
10_10_11
10_10_11_12
i want to put file which is in test: "10_10_asdadfsdfad.txt" in directory "10_10" which is in test2
i want to put file : "10_10_11_asdawqefwkjasd.txt" in directory "10_10_11"
i want to put file : "10_10_11_12_asdafjjhoqwd.txt
" in directory "10_10_12"
I use that code but it didn't do what i want ??
filecnt=0
for file in 10_10*
do
mkdir ../test2/${file} > /dev/null 2>&1
cp "$file" ../test2/${file}/
filecnt=$(( $filecnt + 1 ))
done
echo "$filecnt files copied"
how can we edit it to make that possible .
thank you for your help & time, I need ur reply as faster as possible