Possible Duplicate:
How to loop over the lines of a file?

Let's say I cat a file and I want to run a bash command on each line and write each line as output.

How can I run a bash command on a single line the most succinct way?

cat something | lineBylineInplpace grep -E "spo" > &1

(I forget the standard descriptor symbol = / )

Should output the output of each line to the new file in place with the line it used for input.

I realize that this is very similar to awk. Is there a bash builtin kind of way to make this faster?


The proper way to process a file line by lines is :

   while read -r line; do
       echo "$line"
    done < /path/to/file.txt

See http://mywiki.wooledge.org/BashFAQ/001


  • using unix pipes have a cost, better avoid it for speed

Not the answer you're looking for? Browse other questions tagged or ask your own question.