I found a few similar questions and solution on this topic, but I can't solve the problem in for loops with the previous solution suggested.
fileB:
88569.abcrat
44689.defhom
3702.ghigop
Example of text in file named 234:
9606.jklpan
how is the weather
88569.abcrat
today is a sunny day
44689.defhom
tomorrow will be a rainy day
3702.ghigop
yesterday was a cloudy day
10116.zyxtak
i am happy to see rainbow
desired output for file named 234:
9606.jklpan
how is the weather
10116.zyxtak
i am happy to see rainbow
Then, I will need to repeat the process of searching, matching and deleting for the other files listed in fileA.
fileA:
234
123
456
I was trying:
for i in $(cat fileA); do for j in $(cat fileB); do awk "/$j/ {while (/$j/ && getline>0) ; next} 1" $i; done; done
for i in $(cat fileA); do for j in $(cat fileB); do sed -e "/**$i/$j**/ { N; d; }" $i; done; done
but none of them worked so far. There must be something wrong somewhere. Hope to get some help here. Perhaps some suggestion for better command if possible.
Also, I wonder if i wrote the bold part in the second script correctly?
PS: I am a beginner in scripting. I would appreciate any help given. Thanks!
fileB
infileA
, then delete them along with the immediately following lines? – steeldriver Aug 24 '19 at 14:46file A
andfile A(234)
. – Prvt_Yadav Aug 24 '19 at 17:53