It was explained e.g. here:
how to cut the output of
free command. But I want to do this every few seconds and log it to a file. So I tried:
free -g -s2 | sed -n 's/^Mem:\s\+[0-9]\+\s\+\([0-9]\+\)\s.\+/\1/p' >> memory2.log
but the file stays empty. Why is that and how to fix it?