rlr0304
Group: Members
Posts: 8
Joined: Jan. 2007 |
|
Posted: Jan. 19 2007,10:40 |
|
I'm trying to examine the results of a ping to determine if there was a packet lost. But, I'm having trouble getting a bash pattern to work when there is a space in the pattern.
This works: sResult=$(ping -c 1 192.168.0.120) if [[ $sResult == *packet* ]] then echo packet found else echo packet not found fi
But, if I try to search for "packet loss", I can't get it work.
Bash gives a syntax error if I use the statement: if [[ $sResult == *packet loss* ]] and neither if [[ $sResult == "*packet loss*" ]] or if [[ $sResult == '*packet loss*' ]] works.
Neither does if [[ $sResult == *packet\sloss* ]]
I've also tried searching Google for bash pattern expressions and haven't found any helpful documentation. No one seems to ever search a string that contains spaces.
And yes, I know I can pipe the result of pipe and use grep. But, I'm trying to relearn bash scripting (it been an extremely long time) and I would like to get it work if possible.
Can someone help me out?
TIA,
Richard
|