How to read config kind file using shell script

  Kiến thức lập trình

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

Sam V is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT