I have a file names.txt
[Fruits]
Apple
Banana
Orange
[Vegetables]
Carrots
Spinach
I need to display the Apple, Banana and Oranges if the condition is met as Fruits. Similarly, if the condition is met for Vegetables, show Carrots and Spinach etc.
Can you please guide me how to achieve this using shell script.
I tried using while read line, but I could not get the desired way
New contributor