You're viewing a comment by Cam Hutchison and its responses.
You're viewing a comment by Cam Hutchison and its responses.
I am being sponsored by Syntress since 2007! They bought me an amazing dedicated server to run catonmat on. If you're looking web services in Chicago area, I highly recommend the Syntress guys!
I love to read science books. They make my day and I get ideas for awesome blog posts, such as Busy Beaver, On Functors, Recursive Regular Expressions and many others.
Take a look at my
Amazon wish list, if you're curious about what I have planned reading next, and want to surprise me. :)


You have to be careful doing a read loop over stdin, as any programs inside the loop will also have their stdin attached to the same source as the read command. It occasionally produces screwy results and causes a lot of head scratching.
An alternative is to read from a different file descriptor:
exec 3< input_file.txt # open input_file.txt on fd 3 while read -u 3 -r line ; do # do stuff here done exec 3<&- # close fd 3This potentially has the same problem because fd 3 will be inherited by the programs in the loop, but there is very little likelihood that they will try and read from it, as they may with fd 0 (stdin).
And now we're getting even further from a one-liner...
Comment Responses
Great comment!
Reply To This Comment