Can anyone do this better?

(read line; while [ ! -z "$line" ]; do
  echo "$line";
  read line;
  done;) < iptables-rules.forward

I know I can do:

"; for line in $(cat iptables-rules.forward); do echo "$line"; done;

But, I wanted to try and do it only with built-ins. I really dislike the parenthesis and having two reads in that first one though. What I really want is:

while [ $(read -n4 line) ]; do echo "$line"; done

‘Cept that don’t work.

Leave a Reply

Your email address will not be published. Required fields are marked *