Re Q1,

sed is not losing the first line it's not seeing it.

"while read line"

means that the variable $line contains "the quick". The sed program is not the recipient 
of the pipeline the "while read line" is.
However once the while program has successfully executed the test condition (read line), it then does the body of the loop "sed s/t/T/", connecting what remains in it's standard input to the sed program. The sed program processes all the input and then exits, thus the script returns to the top of the loop. The while read line is executed for a second time and fails with no input and the script ends at the done. I.E the loop only executes once. Run this code for an explanation of what's going on.

$ loop=0
$ cat blah | while read line ; do loop=`expr $loop + 1` ; echo $loop; sed 
s/t/T/ ; done
1
brown fox jumps
over
The lazy
dog
$

I think what you meant to do is;

$ cat blah | while read line ; do echo $line | sed s/t/T/ ; done


Then try this
$ loop=0
$ cat blah | while read line ; do loop=`expr $loop + 1` ; echo $loop; echo 
$line | sed s/t/T/ ; done
1
The quick
2
brown fox jumps
3
over
4
The lazy
5
dog

HTH

Pete


david wrote:
Q1. why does sed lose the first line?

da...@david:~/test$ cat blah
the quick
brown fox jumps
over
the lazy
dog
da...@david:~/test$ cat blah | while read line ; do sed s/t/T/ ; done
brown fox jumps
over
The lazy
dog
da...@david:~/test$

Q2. what does the @ mean?

da...@david:~$ date -d @1174306440
Mon Mar 19 23:14:00 EST 2007

I got this from a google search - the string is from a mysql timestamp which didn't include the @ I can't find a reference to @ in the date man page.

thanks...

David.

--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to