I have a file in below mentioned text format: cat test.txt
"perl-Test::DNS" : [
{
"environment" : "test1",
"hash" : "c8d149b4fc895b214276ca5c90d1181e",
"identifier" : "test1-Test::DNS",
},
{
"environment" : "Test2",
"hash" : "c8d149b4fc895b214276ca5c90d1181e",
"identifier" : "test2-Test::DNS",
},
{
"environment" : "Test3",
"hash" : "c8d149b4fc895b214276ca5c90d1181e",
"identifier" : "test3-Test::DNS",
},
]
"perl-Test::SSH" : [
{
"environment" : "test1",
"hash" : "c8d149b4fc895b214276ca5c90d1181e",
"identifier" : "test1-Test::SSH",
},
{
"environment" : "Test2",
"hash" : "c8d149b4fc895b214276ca5c90d1181e",
"identifier" : "test2-Test::SSH",
},
{
"environment" : "Test3",
"hash" : "c8d149b4fc895b214276ca5c90d1181e",
"identifier" : "test3-Test::SSH",
},
],
I need to grep particular string i.e "perl-Test::SSH : [" from file and print/extract whole lines between '[' and ']' of that string .
I found similar type of question here: Perl: How to extract a string between brackets but this link only extract words between two brackets and i need to extract lines.
Anything that works will be accepted but explanations would help greatly.