4

I am importing data from a large text file into a database and am getting an error on line X of the file. If I look at the line with the less viewer I do not see anything strange, because, most probably, the line has non printable characters. Then I tried to sed the line and check it with a hexdump:

sed -n 2540283p 30gb_large_file.fzp | hexdump -C

again, nothing, most probably, because sed filtered out all non-printable characters.

Any comments how I could see what's happening on the specific line of a large file in hex?

arthur
  • 187

1 Answers1

2

sed should not be "[filtering] out all non-printable characters" - you're not telling it to do so. In fact a simple test on a convenient binary file (the FreeBSD kernel) demonstrates that this is not the case - sed happily passes non-printable characters.

Shame on you for publicly accusing poor innocent sed of doing something heinously wrong without giving it the benefit of a proper test first -- I'll leave it to your guilty conscience to come up with an appropriate act of contrition!

If sed is not giving you any output it's because there's nothing to give -- either that line doesn't exist (maybe the file ends abruptly - Didjya check with wc -l? Maybe there's an EOF in there somewhere it shouldn't be and your program is aborting when it sees it?).
It's also possible that the line in question consists of just a newline or a NUL character (which sed should dutifully return, but which wouldn't be of much use to you in a hexdump)...

voretaq7
  • 80,749