This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: bash question
- From: Mark Blackburn <marklist at fangorn dot ca>
- To: cygwin at cygwin dot com
- Date: Thu, 16 May 2002 23:54:47 -0400 (EDT)
- Subject: Re: bash question
You asked this in the wrong place btw, (I think its a bash specific
questing) but here goes anyways:
#!/bin/bash
i=0
for x in 1 2 3; do
let i=i+1
echo "item $x"
done
echo "Processed $i items"
cat > /tmp/file <<END
item 1
item 2
item 3
END
cat /tmp/file | { export i=0; while read item; do \
let i=i+1 ; \
echo "Read $item $i" ; \
done }
echo "Processed $i items"
rm -f /tmp/file
output is:
item 1
item 2
item 3
Processed 3 items
Read item 1 1
Read item 2 2
Read item 3 3
Processed 3 items
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/