I have some test output, looking like
PASS: tests/test_mutex_rmw
PASS: tests/test_mutex_trylock
PASS: tests/test_malloc_irreg
FAIL: tests/ARMCI_PutS_latency
FAIL: tests/ARMCI_AccS_latency
PASS: tests/test_groups
PASS: tests/test_group_split
PASS: tests/test_malloc_group
FAIL: tests/test_accs
FAIL: tests/test_accs_dla
I want to filter the output to just view the failures. It would be convenient to just copy the text from screen and paste into stdin to pass into grep, e.g.
grep FAIL
and Shift-Ctrl-V (or middle mouse button) to copy the text in.
What I want to see is just
FAIL: tests/ARMCI_PutS_latency
FAIL: tests/ARMCI_AccS_latency
FAIL: tests/test_accs
FAIL: tests/test_accs_dla
But instead, the input pasted in is displayed to screen, and because of buffering the input gets mixed with the final output:
$ grep FAIL
PASS: tests/test_mutex_rmw
PASS: tests/test_mutex_trylock
PASS: tests/test_malloc_irreg
FAIL: tests/ARMCI_PutS_latency
FAIL: tests/ARMCI_AccS_latency
PASS: tests/test_groups
PASS: tests/test_group_split
PASS: tests/test_malloc_group
FAIL: teFAIL: tests/ARMCI_PutS_latency
sts/test_accs
FAIL: tests/test_accs_dla
FAIL: tests/ARMCI_AccS_latency
FAIL: tests/test_accs
FAIL: tests/test_accs_dla
It would make sense to me for the input to first be provided to cat and then passed to grep, cat | grep FAIL
, but that doesn't actually help. The buffer mixup still occurs.
Of course it can be filtered cleanly if the data is placed in a file which is passed to grep. But what I'm looking for is a convenience tool to simply provide light filtering of text copied from the terminal output via the clipboard buffer. How is that best done?
Equivalently, how can pasting be done without echoing to screen (providing data silently as stdin for the command)?
One method is to explicitly switch off echoing,
stty -echo; grep FAIL; stty echo
That does work, but I suspect there are ways of doing it without toggling stty. Do you know other shell-based approaches?
I use bash (on Debian GNU/Linux), but POSIX shell solutions are also interesting.