body { margin: 20px; text-color: #000000; font-family: Verdana, _sans; font-size: 10pt; } .title { font-weight: bolder; font-size: 14pt; } .sub-heading { font-weight: lighter; font-style: italic; } code {color: #035; background-color: #fafaff;} .highlight .lineno { color: #ccc; display:inline-block; padding: 0 5px; border-right:1px solid #ccc; } .highlight pre code { display: block; white-space: pre; overflow-x: auto; word-wrap: normal; }
I’m a Systems/Software Engineer in the San Francisco Bay Area. I moved from Columbus, Ohio in 2007 after getting a B.S. in Physics from the Ohio State University. I'm married, and we have dogs.

Under my github account ( I open-sourced python-aliyun in 2014, I have an outdated python 2 project starter template at python-example, and I have a pretty handy “sshec2” command and some others in tools.

Linux tip 2 - read

October 22, 2009

bash’s built-in read may behave unexpectedly. I’m not sure exactly why, but it looks like it has to do with it expecting to be invoked in a loop. Here’s what I expected to work:

$ echo "thisisfirst thisissecond" | read first second
$ echo $first
$ echo $second

Wait, what? But I use read all the time for while loops like this:

cat file | while read col1 col2 col3; do
    printf "col1: %sncol2: %sncol3: %snn" $col1 $col2 $col3

and that has never let me down. So why can’t I do it this way? I don’t really know, do you? Here’s a work around:

echo "thisisfirst thisissecond" | while read first second; do
    #do junk here

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. :wq