It's unclear why you think adding literal single quotes around a host name would be useful; host names do not have single quotes in them.
ping "$message"
passes the string in message
as a single argument to ping
.
echo '55 55'
quotes the string 55 55
as a single string, but echo
is not very good at showing you what it was actually passed as arguments. Probably a better tool to test with is printf
. Compare
bash$ message='55 55'
bash$ printf ">>%s<<\n" $message
>>55<<
>>55<<
bash$ printf ">>%s<<\n" "$message"
>>55 55<<
bash$ printf ">>%s<<\n" \'$message\'
>>'55<<
>>55'<<
bash$ printf ">>%s<<\n" '$message'
>>$message<<
bash$ printf ">>%s<<\n" "'$message'"
>>'55 55'<<
bash$ ping "'55 55'"
ping: cannot resolve '55 55': Unknown host
bash$ ping -c 2 '55 55'
PING 55 55 (0.0.0.55): 56 data bytes
ping: sendto: No route to host
Request timeout for icmp_seq 0
--- 55 55 ping statistics ---
2 packets transmitted, 0 packets received, 100.0% packet loss
bash$ ping 55 55
usage: ping [-AaDdfnoQqRrv] [-c count] [-G sweepmaxsize]
[-g sweepminsize] [-h sweepincrsize] [-i wait]
[-l preload] [-M mask | time] [-m ttl] [-p pattern]
[-S src_addr] [-s packetsize] [-t timeout][-W waittime]
[-z tos] host
ping [-AaDdfLnoQqRrv] [-c count] [-I iface] [-i wait]
[-l preload] [-M mask | time] [-m ttl] [-p pattern] [-S src_addr]
[-s packetsize] [-T ttl] [-t timeout] [-W waittime]
[-z tos] mcast-group
Apple specific options (to be specified before mcast-group or host like all options)
-b boundif # bind the socket to the interface
-k traffic_class # set traffic class socket option
-K net_service_type # set traffic class socket options
-apple-connect # call connect(2) in the socket
-apple-time # display current time
In summary, you need to understand the difference between syntactic quotes (quoting which you use to indicate to the shell that something is a single string) and literal quotes (characters which are part of a string itself, and do not quote anything from the shell), and probably also the difference between single quotes (syntactic quotes which preserve the string within them completely verbatim) and double quotes (syntactic quotes which group the string as one argument, but allow the shell to perform backslash processing, variable interpolation, etc on the value).