It was explained e.g. here:
Get separate used memory info from free -m command
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?
sed
command never finishes. I will be right back with a solution :)-u
flag forsed
. That fixes the problem :)