ifconfig's output has a blank line between each interface, making it perfectly suited for reading and processing in "paragraph mode" in a scripting language like awk or perl. A "paragraph" is any block of text separated from other blocks by one-or-more empty lines.
For example:
ifconfig | awk -v RS='' '/^s1-eth[12]:/ {print}'
The awk example above sets awk's record separator (RS) to the empty string, causing it to process paragraphs instead of individual lines. In this case, each paragraph is tested for a match against ^s1-eth[12]: and is printed if it matches.
Example output from my system:
$ ifconfig | awk -v RS='' '/^(ppp0|lo):/ {print}'
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 64237556 bytes 36962222928 (34.4 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 64237556 bytes 36962222928 (34.4 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1412
inet ip.ip.ip.ip netmask 255.255.255.255 destination ip.ip.ip.ip
ppp txqueuelen 3 (Point-to-Point Protocol)
RX packets 28220997 bytes 19305565357 (17.9 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 21719890 bytes 3009382446 (2.8 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Note that this is no longer printed in paragraphs - there is no empty line between each interfaces "record". If you want paragraphs in your output, set the output record separator (ORS) to two newlines (\n\n). e.g.
ifconfig | awk -v RS='' -v ORS='\n\n' '/^(ppp0|lo):/ {print}'
To do something similar with ip's output rather than ifconfig's is slightly more complicated. ip doesn't produce neatly paragraph-separated output. It does, however, output each interface in a block with the interface's number followed by a colon and a space at the beginning of a line, with the rest of that interfaces details following.
To make use of this, set RS to the regular expression ((^|\n)[0-9]+:). That matches any digits followed by a colon and a space ([0-9]+:) that are either at the beginning of the file (^, to match the first record, which would otherwise be skipped) or immediately after a newline.
For example, on my system:
$ ip addr | awk -v RS='(^|\n)[0-9]+: ' '/^(lo|eth0):/ {print}'
lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
link/ether 01:33:ed:b0:13:a9 brd ff:ff:ff:ff:ff:ff
(my eth0 doesn't have any IP addresses because I have it set up as a bridge for VMs and docker containers. The IP addresses are on the br0 interface instead)
ifconfigwill give you different output depending on what distro you're running. Consider usingipinstead.