I currently follow memory usage of my machine using the following loop in bash :
echo " date time $(free -m | grep total | sed -E 's/^ (.*)/\1/g')" | tee -a log20201113.txt
while true; do
echo "$(date '+%Y-%m-%d %H:%M:%S') $(free -m | grep Mem: | sed 's/Mem://g')" | tee -a log20201113.txt
sleep 1
done
Which give me a txt file with something like that (modified values) :
date time total used free shared buffers cached
2020-11-13 22:55:56 8333 627 5705 0 1638 685
2020-11-13 22:55:57 8333 677 5656 0 1638 685
2020-11-13 22:55:58 8333 725 5607 0 1638 685
2020-11-13 22:55:59 8333 773 5560 0 1638 685
I am trying to output that to a csv file instead. Putting a csv extension doesn't seems to work because it doesn't include separators. How would I include separators and put that in a csv file instead ?