This is a discussion on Can someone please explain this to me within the Shell scripting forums, part of the Development/Scripting category; if [ `/opt/bin/ps ax | grep -c transmission` -gt 1 ] then echo "<td>Running</td>" else echo "<td>NOT running</td>" fi This ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
if [ `/opt/bin/ps ax | grep -c transmission` -gt 1 ]
then echo "<td>Running</td>" else echo "<td>NOT running</td>" fi This is part of script that generate web site with some router statistics. What I don't understand is the "-gt 1" part. What I think it does is decrease output of grep -c by one. But in different script I have "if [ $count -eq 0 ]" whole script is here . If someone can point me to man page where I can find more info about it. thanks Peter |
| Sponsored Links | ||
|
|
|
|||
|
The -c switch for grep returns a count of lines that match the given pattern.
By saying Code:
if [ `/opt/bin/ps ax | grep -c transmission` -gt 1 ] The -gt just means greater than. There are others of a similar form : lt -- less than eq -- equal to ne -- not equal to And so on and so forth. |