With `ngrep`, you can do this:
ngrep '\xff{6}(.{6})\1{15}'
That matches 0xff 6 times, followed by any 6 bytes, followed by those same 6 bytes repeated 15 more times. I confirmed that matches a packet generated by `wakeonlan`.
`ngrep` has options that are useful for scripting (e.g., `-W single` to have a single line per matched packet, `-l` to defeat buffering, `-t` for timestamps, `-q` to silence other output).