In addition to the previous comments, using for var in `cat file` is usually wrong. The file will not only be split by newlines, but by other symbols (defined in shell variable IFS; spaces, newlines and tabs by default) too. If you need similar behaviour, you need perl -lpe 'join "\n",split/[\t ]/' file. EDIT: fixed code