I'm implementing a sort-function in my script, but I have trouble in doing so:
what I want to achieve is the following:
bash script --sort 44 55 1 23 44
output:
Pinging to 192.168.1.1 succes
Pinging to 192.168.1.23 failed
Pinging to 192.168.1.44 failed
Pinging to 192.168.1.55 failed
The pinging and stuff already works, I just don't know how to make a list with the arguments, sort them and (save the list) then use them in the ping command (by using for var in $SORTEDLIST do <ping-command> done
.
I already had this:
SORTEDLIST="$SORTEDLISTS $@"
for var in $SORTEDLISTS
do
echo "$var"
done | sort -n -u
The echo was just a test, but there I'll have to save the list somehow. Any ideas?