список для vms:
virsh list
получить MAC vm из имени
virsh domiflist debian8
выполнить сканирование подсети vm с помощью grep (MAC должен быть заглавным)
nmap -sP 10.0.0.0/24 | grep 52:54:00:FD:1F:92 -B 3
результат
Nmap scan report for 10.0.0.173
Host is up (0.0012s latency).
MAC Address: 52:54:00:FD:1F:92 (QEMU Virtual NIC)
Поскольку вы изначально просили sed
решение, я добавляю одно:
sed '/./{H;1h;$! d}
g;/{p}$/d
s#^{p}.*#&\n{/p}#;p
s/.*/{p}/;h;d' somefile.txt
Пояснение
Я бы предложил awk подход:
awk 'NR>1 && NF{$0="{p}" RS $0 RS "{/p}"}1' file
Вывод:
Section 5. General Information About Project Gutenberg-tm electronic works.
{p}
Description
{/p}
{p}
Professor Michael S. Hart is the originator of the Project Gutenberg-tm concept of a library of electronic works that could be freely shared with anyone. For thirty years, he produced and distributed Project Gutenberg-tm eBooks with only a loose network of volunteer support.
{/p}
{p}
Project Gutenberg-tm eBooks are often created from several printed editions, all of which are confirmed as Public Domain in the U.S. unless a copyright notice is included. Thus, we do not necessarily keep eBooks in compliance with any particular paper edition.
{/p}
RS
- разделитель записей awk, по умолчанию новая строка \n
NR>1
- пропускает первую строку header
NF
- указывает на общее количество полей строки (с учетом непустых строк)