bug-bash
[Top][All Lists]
Advanced

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

Re: ReadLines and Substraction


From: Andres Perera
Subject: Re: ReadLines and Substraction
Date: Mon, 14 Mar 2011 13:07:42 -0430

benign dead code:

>>>
>>> If you can help me with this, will be very happy for that. Thanks in
>>> advance.
>
> #!/usr/bin/env bash
>
> set -e
>
> if [[ $(type -t 'mapfile') != 'builtin' ]]; then
>       function mapfile
>       {
>               while getopts C:c: f
>               do
>                       case $f in
>                       C) cmd=$OPTARG;;
>                       c) rep=$OPTARG;;
>                       esac
>               done
>               shift $((--OPTIND))
>
 -              i=0
>               while read -r n
>               do
 -                      !((i % rep)) && eval "$cmd"
 +                      ((n % rep)) || eval "$cmd"
>                       : $(($1[i++] = n))
>               done
>       }
> fi
>
> (((files = $#) >= 2))
>
> while (($#))
> do
>       [[ $1 ]]
>       mapfile -C'let ++lno #' -c1 par_$# < <(egrep '^[0-9]+$' "$1")
>       shift
> done
>
> ((lno && ((lno / files) == ${#par_1[@]})))
>
> for i in ${!par_1[@]}; do
>       for ((j=1; j <= files-1; j++)); do
>               : $((par_$files[i] -= par_$j[i]))
>       done
>       printf '%d\n' $((par_$files[i]))
> done
>
> exit



reply via email to

[Prev in Thread] Current Thread [Next in Thread]