0

I use xev to debug x11 events for a window. I can filter events using grep, for example: xev -id windowid | grep FocusIn. I want to append time to each output from the above command (date +"%T.%N") . I need to know when each event occured. Is it possible ? How to achieve that ?

Edit1

Following command works:

xev -id windowid | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }'

but with grep there is no output:

xev -id windowid | grep FocusIn | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }'

When I use grep and ts there is also no output:

xev -id windowid | grep FocusIn | ts

How to fix that ?

Irbis
  • 11,537
  • 6
  • 39
  • 68

1 Answers1

2

You can pipe the output through the ts command, if it is available on your system and if prepending (instead of appending) the timestamp is fine for you.

Otherwise you can use awk as described here:

Is there a Unix utility to prepend timestamps to stdin?

Community
  • 1
  • 1
SukkoPera
  • 621
  • 4
  • 8