I have a set of folders, inside each folder I have several sub-folders. In each sub folder there is a file called result.txt I need all the result.txt to be copied to other location renaming result files.
folders:
abc1
efg1
doc2
ghih
sub-folders:
in aaa1
1.abc1.merged
2.abc1.merged
3.abc1.merged
4.abc1.merged
in efg1
1.efg1.merged
2.efg1.merged
3.efg1.merged
4.efg1.merged
5.efg1.merged
...
...
so on all of the sub-folders contain result.txt in a single different folder with all the result files renamed to result1.txt,result2.txt etc.
I tried to set name of sub-folder as a variable in shell script and made a loop to go in to the sub-folder and copy the result.txt to other path and rename it by mv command.But only the result.txt file from one subdirectory each is copied not the all.
I tried with following commands:
cp $folder/$subfolder/resu*txt ../tsv/$newfolder/
(I previously assigned variables)
mv ../tsv/$newfolder/resu*txt ../tsv/$newfolder/results$tts.txt
(I defined $tts as number of subfolders in the folder)
This copied the result.txt from only first sub-folder in each of parent folders.