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

Re: [bash] Einlesen einer Datei



Hallo,

On 2005.01.20 11:50, Thilo Engelbracht wrote:
          while [ -z "$quota" ]
          do
               read zeile
               account=`echo $zeile | cut -d : -f 2 | cut -d " " -f
2-`
          done


Der Code ist vielleicht etwas umständlich - aber es funktioniert
problemlos. Nun möchte ich jedoch noch erreichen, dass ich in der
Text-
datei auch Leerzeilen und Kommentare einfügen kann, beispielsweise so:

grep is your friend. :-)
          do
               read zeile
if [ `echo "$zeile" | grep -v "^\w*$" | grep -v "^\w*#" ]; then account=`echo $zeile | cut -d : -f 2 | cut -d " " -f 2`
		fi
          done

Ist jetzt nur ungetestet auf die Schnelle hingeworfen; kann also sein, dass die Syntax nicht ganz korrekt ist. Waere bestimmt auch sinnvoll, das in eine Funktion auszulagern, weil Du ja so viele Sachen einlesen willst.

Schoenen Gruss,
Andreas

Attachment: pgpoDAKam5DtQ.pgp
Description: PGP signature


Reply to: