Re: Pipe ueber FIFO

David Haller <[email protected]> Fri, 8 Oct 2010 21:26:55 +0200
Newsgroups gmane.linux.suse.programming
Message-ID <[email protected]>
Hallo,

Am Fre, 08 Okt 2010, Thomas Moritz schrieb:
>Am Freitag, 8. Oktober 2010 11:39:35 schrieb Thomas Moritz:
>> Am Freitag, 8. Oktober 2010 07:44:43 schrieb Thomas Moritz:
>
>Bevor David wieder was zu meckern hat... :-)
>Den FIFO erzeuge ich jetzt aus Sicherheitsgruenden mit mktemp.
>
>#!/bin/sh

Darf's auch bash sein (ne alte 2.03 reicht schon)?

>myfifo=$(mktemp myfifo.XXXXXX)
>rm -f $myfifo
>mkfifo $myfifo
>
>trap "rm -f $myfifo" HUP INT TERM EXIT
>
>x=0
>cat name.txt > $myfifo &
>while read name; do
>  x=`expr $x + 1`

expr ist extern, also teuer.

>  echo "$name"
>done <$myfifo
>echo "Var x Ausserhalb von while= $x"

Warum so umst-AƤndlich?-b

====
#!/bin/bash
while read name; do
    x=$((x+1));
    echo "$name";
done < <(find ...)
echo "$x Dateien"
====

Ansonsten lies mal http://cboltz.de/de/linux/bash/

HTH,
-dnh

-- 
Fertility is hereditary.  If your parents didn't have any children,
neither will you.