Y
Y
Yevgeniy Bondarev2020-02-05 18:38:27
bash
Yevgeniy Bondarev, 2020-02-05 18:38:27

What's wrong with the attached bash one-liner?

echo $(for i in {100..104}; do ping –c 1 192.168.55.$i >/dev/null && echo 192.168.55.$i is up; done)


upd1: Throws an error: usage: ping [-AaDdfnoQqRrv] [-c count] [-G sweepmaxsize] etc.

upd2: The problem was in a dash instead of a hyphen, in the -c section 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Priluzkiy, 2020-02-05
@Oxyd

echo $(for i in {100..104}; do ping 192.168.55.$i -c 1 >&/dev/null && echo 192.168.55.$i is up; done)

PS: But in fact, it's better to do it like this:
seq 100 104|xargs -i sh -c 'ping -c 1 192.168.55.{} >&/dev/null && echo 192.168.55.{} is up'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question