Aqui vai você.
#!/bin/sh
# Go to where the files are located
cd /somedirectory/archive/test
# Save IFS variable (if needed) and set it to newline.
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
# List the files and for each one save the size, time and name. Then, save results.
echo '"File Name","size","date"' > output.csv
for line in 'ls -lrt *.txt.gz'; do
size=$(echo $line |awk -F ' ' '{print $5}');
date=$(echo $line |awk -F ' ' '{print $6" "$7}');
file=$(echo $line |awk -F ' ' '{print $9}');
echo '"'$size'","'$date'","'$file'"' >> output.csv
done
# Return IFS to original status.
IFS=$SAVEIFS
code=$?
exit $code
Resultado:
$ cat output.csv
"File Name","size","date"
"0","Jun 3","XXXXX_20140530_0401_28.txt.gz"
"0","Jun 3","XXXXX_20140530_0401_29.txt.gz"
"0","Jun 3","XXXXX_20140531_0401_01.txt.gz"