A.txt contains:
/*333*/
asdfasdfadfg
sadfasdfasgadas
@@@
/*555*/
hfawehfihohawe
aweihfiwahif
aiwehfwwh
@@@
/*777*/
jawejfiawjia
ajwiejfjeiie
eiuehhawefjj
@@@
B.txt contains:
555
777
I want to create the loop, for each string found in B.txt, then output the '/*'[the string] until right before the first '@@@' met to each own file (the string name is also used as file name). So based on the sample above, the result should be :
555.txt, which contains:
/*555*/
hfawehfihohawe
aweihfiwahif
aiwehfwwh
and 777.txt, which contains:
/*777*/
jawejfiawjia
ajwiejfjeiie
eiuehhawefjj
I tried this script but it outputs nothing:
for i in `cat B.txt`; do echo $i | awk '/{print "/*"$1}/{flag=1} /@@@/{flag=0} flag' A.txt > $i.txt; done
Thank you in advance