[bash] вызов программы при нахождении совпадения в тексте файла

1 view
Skip to first unread message

Dmitry A. Zhiglov

unread,
Mar 2, 2013, 3:27:26 AM3/2/13
to Debian Russian MailList
Добрый день,


Ищу способ реализовать пинг похожий на этот поиск
find . -type f -exec file '{}' \;
но в ином ключе.

Есть файл, который содержит много текста.
Из этого файла могу выудить нужную строку, вот так
cat /etc/hostlist.conf | grep host | awk '{print $2}'
в результате получаю список, например такой

ip_usa.tld
ip_europe.tld
ip_australia.tld

Как сделать так, что бы при нахождении в файле host_* сразу же
исполнялась нечто такое

ping -c2 ip_usa.tld

?

Спасибо

Mikhail A Antonov

unread,
Mar 2, 2013, 3:33:52 AM3/2/13
to debian-...@lists.debian.org
02.03.2013 12:27, Dmitry A. Zhiglov пишет:
> cat /etc/hostlist.conf | grep host | awk '{print $2}'
grep host /etc/hostlist.conf | awk '{system("ping -c2 " $2)}'

--
Best regards,
Mikhail
-
WWW: http://www.antmix.pp.ru/
XMPP: ant...@stopicq.ru


signature.asc

Vladimir Zhbanov

unread,
Mar 2, 2013, 4:14:40 AM3/2/13
to debian-...@lists.debian.org
On Sat, Mar 02, 2013 at 12:33:52PM +0400, Mikhail A Antonov wrote:
> 02.03.2013 12:27, Dmitry A. Zhiglov пишет:
> > cat /etc/hostlist.conf | grep host | awk '{print $2}'
> grep host /etc/hostlist.conf | awk '{system("ping -c2 " $2)}'

или
grep host /etc/hostlist.conf | awk '{print $2}' |xargs -L1 ping -c2

--
http://vzhbanov.byethost33.com


--
To UNSUBSCRIBE, email to debian-russ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/2013030209...@localhost.localdomain

Dmitry A. Zhiglov

unread,
Mar 2, 2013, 7:16:26 AM3/2/13
to debian-...@lists.debian.org, Debian Russian MailList
2013/3/2 Mikhail A Antonov <ba...@solarnet.ru>:
> 02.03.2013 12:27, Dmitry A. Zhiglov пишет:
>> cat /etc/hostlist.conf | grep host | awk '{print $2}'
> grep host /etc/hostlist.conf | awk '{system("ping -c2 " $2)}'

Спасибо Михаил!


--
To UNSUBSCRIBE, email to debian-russ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
Archive: http://lists.debian.org/CAHMFuOvsFZe9dBVumPjZODuf...@mail.gmail.com

Reply all
Reply to author
Forward
0 new messages