I played a game where I moved my bishop to c4 and queen to h5 while Black was busy advancing h and g pawns (and trading its rook for my knight on h3), and when I thought I played the final move Qxf7 checkmate, it calmly played ... Kxd8
I guess making illegal moves is its only way of acknowledging defeat.
In the late 1970s, I bought a chess computer at J. C. Penney, the one in a brown plastic case with the chessboard printed on top and a keypad to the right with a red LED display. I returned it after about a week because it cheated. Whenever I moved to take its King/Queen, it would call an illegal move, and claim that its King/Queen was on the other side of the board. I've wondered what glitch in programming would create that behavior.
That's the same as a typical Unix script cobbed together with these tools. When the input data isn't of the expected form (a regex doesn't match, or matches in the wrong place, or whatever), there is often still a nonfailing behavior of some kind.
For awk, start with the book by Kernighan/Aho/Weinberger. The PDF of the first edition is freely available on archive.org, and a second edition has been announced. Chapter 2 of the first edition is only 40 pages, and describes all language features.
For sed, the best resource is likely the free "UNIX Bookshelf" from O'Reilly that can be found online; this contains a book specifically focusing on Sed and Awk.
I've shared this before, but this sed tutorial made me a pro. [0] Even if you don't use it for more complex things, you may find there are faster ways to do the things you are now.
Perl is probably overkill for 99% of one-liners and may not be available on as many environments as awk/sed are, but I advocate that folks do whatever is best for them in their environment and if that's Perl for you, rock it out!
awk can do much more than sed. And, with patience, you could even write a Z-machine interpreter on it as some guy did with postscript. You might have to convert the binary input to hex first with xxd/od in order to parse the opcodes in a nice way, but everything else would be simulated from awk.
black removed its own queen when I placed its king into checked :P then it moved its king from check to the space to the left staying in check :) :P
impressive but the graphics need to be much bigger.
Would be good to have some indication that is is my move and show the move that the chess.sed made, would also be good to place all moves into chess.log :P