[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: помогите упростить условие bash



On 29.11.13 0934 (+0400), Vladimir Skubriev wrote:
> check_rebuild_status(){
>         if [ $(grep "recovery" /proc/mdstat -c) -ne 0  ]; then
>                 return 0
>         else
>                 return 1
>         fi
> }
> 
> Чтобы было более элегантно.

check_rebuild_status(){
    grep -q recovery /proc/mdstat
    return $?
}

-q, --quiet, --silent
Quiet; do not write anything to standard output. Exit immediately with
zero status if any match is found, even if an error was detected.  Also
see the -s or --no-messages option. (-q is specified by POSIX.)


Reply to: