FG

How to pipe awk output (with periodic, continuous input) to output file?

Fresh3 days ago
Mar 15, 202616908 views
Confidence Score0%
0%

Problem

I am trying to write a command that pipes the continuous output of a free command (run every second) to an awk command that parses a specific value (available free memory) and outputs this to a file with a timestamp. Here are my current attempts at the command: And alternatively, after a bit of Goo…

Error Output

free -mto -s 1 | awk '/Mem/ { print strftime("%r") "," $4 }' >>memOut

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How to pipe awk output (with periodic, continuous input) to output file?

Low Risk

You have to flush the buffer to see something in during the execution: Here's an alternative version:

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment