On Thu, Feb 12, 2004 at 03:12:28PM +0200, Costi wrote: > Cam pe la 02/12/2004 02:58 PM, Viorel Anghel scrise: > > >On Thu, Feb 12, 2004 at 01:54:36PM +0200, Costi 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 > >> > >> > > > >pe linga ce au spus ceilalti, ce anume vrei tu sa faci aici??? > >echo $1 | tr -d '[:space:]' ??? $1 este un parametru, nu poate sa aiba > >spatii in > > > > Credeam ca in $1 umple cu un "\n", si vroiam sa sterg spatiile albe din > el. Ce se intimpla, $1 nu mai exista? > > #!/bin/bash > cat data | while read line > do > set -- $line > # $1=ip-ul, $2=portul > if [ -n $1 ]; then
try if [ -n "$1" ] > echo ip=192.168.0.$1 port=$2 > fi > done > > Output, la fel: > 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= > > -- > Ce nu te omoara ti-o intareste. > > > > --- > Detalii despre listele noastre de mail: http://www.lug.ro/ > -- ___ <o-o> Viorel ANGHEL <vang @ lug.ro> [`-'] -"-"- In Linux We Trust. --- Detalii despre listele noastre de mail: http://www.lug.ro/
