cmd > out.txt 2> err.txt # redirect stdout to out.txt and stderr to err.txt
cmd > out.txt 2>&1       # redirect both to out.txt
shopt -s nullglob      # in case no *.txt files 
for f in *.txt
do
   echo $f
done
while true; do echo 'Hit CTRL+C'; sleep 1; done