Stan suggested,
R> One could replace the last line with something (untested) like:
R> ls -1 | egrep '^-' | tee /tmp/$$ | xargs cat && \
R> touch ./-- && cat /tmp/$$ | xargs rm -f ./-- && rm /tmp/$$
Era asked,
E> If you're in this deep a mess, why not just
E> ls -1 | sed -n '/^-/s%.*%cat ./& ; rm -f ./&%p' | sh
That calls cat and rm once each for every message in the folder. The same
can be done without sed and the extra sh:
ls -1 | \
while read filename
do case ./$filename in
-*) cat ./$filename && rm -f ./$filename ;;
esac
done
Stan's suggestion calls cat and rm only once per line of xargs's output.