Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • So to ping my ip-addresses I only have to input ping c -1 "192.168.0.$i" in the for loop? Like this: array=($(printf '%s\n' "$@"|sort -u)) SortNumbers(){ echo ${array[@]} for i in $({array[@]};do ping 192.168.0.$i done } case -sort ) SortNumbers;; esac Commented Jun 13, 2015 at 12:08
  • No, you don't need to use the sortNumber function, and the echo. Commented Jun 13, 2015 at 12:15
  • @gladius I have added a complete code sample for your particular case, You don't need to use any function to do the sorting, it's just an extra line above your for loop. Commented Jun 13, 2015 at 12:19
  • okay, Tnx. But I use it in a case. So i will put the for.... - .. done in a function and the array in the begin of my script. So i can do this: bash test.sh -sort 50 40 80 20 for example Commented Jun 13, 2015 at 12:22
  • @gladius it won't work like that... I am updating my answer with a function solution... Commented Jun 13, 2015 at 12:33