On Thursday 12 February 2004 13:54, you wrote:
> Cu programul read_data citesc datele din "data". Problema este ca nu pot
> sa-l fac sa ignore liniile goale. Ce gresesc?
>
> "data" file
> 3 1444
> 4 1445
> 5 1446
> <aici e endline>
> <aici e endline>
> <aici e endline>
>
>
> "read_data" file
> #!/bin/bash
> cat data | while read line
> do
>   set -- $line
>   # $1=ip-ul, $2=portul
>   if [ -n `echo $1 | tr -d '[:space:]'` ]; then
>     echo ip=192.168.0.$1 port=$2
>   fi
> done
 verifici daca o citit o valoare canci in ifu' ala. Din man bash:
   -n string
       string True if the length of string is non-zero.
   if [-n $line] bla bla

>
>
>
> OUTPUT:
> ip=192.168.0.3 port=1444
> ip=192.168.0.4 port=1445
> ip=192.168.0.5 port=1446
> ip=192.168.0. port=
> ip=192.168.0. port=
> ip=192.168.0. port=
> ip=192.168.0. port=
> ip=192.168.0. port=
> ip=192.168.0. port=

-- 
I tought i taw a putty cat...I did! I did taw a putty cat!


--- 
Detalii despre listele noastre de mail: http://www.lug.ro/


Raspunde prin e-mail lui