I have this command (for pomodoros):
play -n synth 25:00 pinknoise
I don't want to silent completely the output (-q option), just the header (grep don't work).
Normal output:
File Size: 94.3T
Encoding: n/a
Channels: 1 @ 32-bit
Samplerate: 48000Hz
Replaygain: off
Duration: unknown
In:0.00% 00:00:01.02 [00:00:00.00] Out:49.2k [======|======] Hd:1.3 Clip:0
Desire filtered output: 01.02 (this number is updated, like in a cURL or pv progress bar)
How can I grep just that part of the output?
So far:
For some reason the output is sent to stderr, like with "Permission denied" from
find. An easy way to test is to add at the end2> /dev/null.Maybe the reason why sox/play output to stderr is because it supports writing the output to standard output (stdout) using the special filename
-(see sox man page).But
|& grep "^In"won't work. Using|& tee log.txtit seems uses the delete character to update the last line.I tried
grep --line-buffered,unbufferandstdbuf(after reading this and this) with some great progress:play -n synth 25:00 pinknoise 2>&1 | stdbuf -oL tr '\r' '\n' | grep -o '[0-9][0-9]*\.[0-9][0-9] '
That's very close!
Is possible to get only just one updated line like was on the original output? Maybe like this loop with echo -ne.
I'm not sure why something like | grep --line-buffered . doesn't work, neither removing trailing newline: | tr -d '\n'. I need something like tail -f -n 1.