perl -nE '/([\r\n]{1,2})/; print(unpack("H*",$1))' in.txt 0d0a