2

This has been asked a dozen times already, but the answer is always "see what type of file vi says it is and deduce from that" or "run it through cat and see if the windows line endings are rendered" or "run it through egrep to see if egrep finds instances of one type of line ending or another".

Is there not a reasonably easy way to just directly view which characters are used? Ideally I would just have a flag on cat that spat out escape characters in their human-readbable representation instead of rending them as whitespace.

1
  • In what language? Or are you asking for a hex editor?
    – SLaks
    Commented Oct 19, 2011 at 20:26

3 Answers 3

4

You can also use "cat -v", it doesn't show everything but it does show "\r\n" as "^M":

$ cat -v WKB2.gff | head
##gff-version 2^M
# seqname   source  feature start   end score   strand  frame   attributes^M
CP007446    -   source  1   2527978 .   +   .   organism "Snodgrassella alvi wkB2" ; mol_type "genomic DNA" ; strain "wkB2" ; db_xref "taxon:1196094"^M

$ cat -v PAO1.gff | head
##gff-version 3
#!gff-spec-version 1.20
#!processor NCBI annotwriter
##sequence-region AE004091.2 1 6264404
##species http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=208964
AE004091.2  Genbank region  1   6264404 .   +   .   ID=id0;Dbxref=taxon:208964;Is_circular=true;gbkey=Src;genome=chromosome;mol_type=genomic DNA;strain=PAO1
3

try 'od' http://en.wikipedia.org/wiki/Od_(Unix)

0
2

head -1 file.txt | hexdump -C

Look at the last bytes printed out and you should be able to tell what the line endings are.

2
  • I don't see it... i see whitespace Commented Oct 19, 2011 at 20:51
  • 1
    You should see output like: 00000000 48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21 0a |Hello, World!.| which shows that the line break is just 0a, which is LF, whereas 0d 0a would be CRLF
    – bames53
    Commented Oct 19, 2011 at 21:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.