Results 1 to 3 of 3
Hi,
I was going through a file containing hundreds of lines of codes having conditional statement written as:
log()
{
echo $@
}
num=$(/usr/bin/rsh <one_machine> -l root 'ls -d /home/user/db* ...
- 06-13-2007 #1
Confusion over a small conditional script
Hi,
I was going through a file containing hundreds of lines of codes having conditional statement written as:
log()
{
echo $@
}
num=$(/usr/bin/rsh <one_machine> -l root 'ls -d /home/user/db* 2> /dev/null' | wc -w)
(( num > 0 )) && log "db info:"
so,if here the return value(stored in variable "num" is greater than 0) then
"db info"will be echoed on the screen.
But if i need to do more commands execution if the return value is > 0 then how can i add more statements here.
In past i've used something like this:
num=$(/usr/bin/rsh <one_machine> -l root 'ls -d /home/user/db* 2> /dev/null' | wc -w)
if [ "$num" -gt "0" ]; then
statement 1
statement 2
..................
statement N
fi
but how this can be used here ?
~amit
- 06-13-2007 #2Linux User
- Join Date
- Jun 2007
- Posts
- 318
(( num > 0 )) && (log "db info:"; statement; statement)
- 06-14-2007 #3


Reply With Quote
