I have a file with the following structure:
4168 Targus
1010 Wireless Compact Laser Mouse
4242 USB Design by Example
4201 Buttons and Lights HID device
4220 Echo 1 Camera
4255 GoPro
1000 9FF2 [Digital Photo Display]
2000 HD2-14 [Hero 2 Camera]
4317 Broadcom Corp.
0700 U.S. Robotics USR5426 802.11g Adapter
0701 U.S. Robotics USR5425 Wireless MAXg Adapter
0711 Belkin F5D7051 v3000 802.11g
0720 Dynex DX-BUSB
0721 Dynex DX-EBUSB
4348 WinChipHead
5523 USB->RS 232 adapter with Prolific PL 2303 chipset
5537 13.56Mhz RFID Card Reader and Writer
5584 CH34x printer adapter cable
4572 Shuttle, Inc.
4572 Shuttle PN31 Remote
Here each section is separated by non-whitespace character. I do not know the beginning letter of each section and its line number in the file.
What is the way to read lined between two sections, either in bash or in python 3?
In the above example, the first section will be line 4168 till next a line before the next line that starts with a non-whitespace character. So the first section is having a line
1010 Wireless Compact Laser Mouse
while the second section consists of:
4201 Buttons and Lights HID device
4220 Echo 1 Camera
Section selection is done by the given input. e.g. if 4242 is input, then the desired section to read will be:
4201 Buttons and Lights HID device
4220 Echo 1 Camera
Please note that I do not know the line number of 4242.
the first section will be line 4168
, which seems to indicate that4168
in the example text is a line number that you have inserted.Targus
andUSB Design by Example
...