#!/bin/sh for i in ZP*.TXT; do sed -r 's/\x1b\[\?7h//g; s/\x1b\[255D//g; s/\x1b\[40m(\r\n)+\x1b\[0m/\x1b\[40m\x1b\[0m/g;' $i | tr -d '\n' > out/$i echo -n "" >> out/$i echo "$i > out/$i" done