Start with "file" command. Move towards way of identifying ad hoc text based formats.
BD-125 Ad Hoc format recognizers
BD-666 DTS extractor for PRONOM format identification