Reading from text

Tim Chase python.list at tim.thechases.com
Tue Feb 17 13:44:07 EST 2009


> Assuming this is a real task and not a homework problem, then
> I'd do it this way:
> 
>   $ cd [directory containing 50 test files]
>   $ (for file in *; do head -n11 $file | tail -n5; done) >/path/to/results-file.txt

I'd use sed:

   sed -ns 7,11p /source/path/*.txt >/path/to/results.txt

hard to get much more concise than that with any common tool :)

-tkc







More information about the Python-list mailing list