Janis Papanagnou <
janis_pa...@hotmail.com> wrote:
> On 12.10.2012 19:17, Dave Gibson wrote:
>> Roberto Zuelli <
rober...@gmail.com> wrote:
>>> Hello,
>>>
>>> I want to assigne to each node a parameter (called type) that
>>> represents its type.
>>>
>>> I have a txt file like this:
>>> Node Area Pd Ls
>>> AA £ AQ 0.00 0.00
>>> BB £ BW 0.00 0.00
>>> CC £ BE 10.00 0.00
>>>
>>> I want to assigne to the first node of the file with Pd=0.00 and
>>> Ls=0.00: type=0.
>>> For the remaining nodes, also if they have Pd=0 and Ls=0, type=1.
>>
>> awk '
>> NR == 1 { print $0 " Type" ; next }
>> $4 + $5 == 0 { $0 = $0 " " t + 0 ; t = 1 }
>
> If Pd or Ls values could be negative, and are, say something like
> 2.00 and -2.00, then this condition will fail.