#!/bin/sh for file in `ls *.txt | grep test`; do awk '/Learned/ {print $2 " " $7}' $file > `basename $file .txt`.dat; done