I tried to write a script that fixes it.
Make a file executable, run it with source filename as a single param.
./head-1.sh
Code:
#!/bin/sh
filename=$1
#filename="filename"
size=`stat -f %z ${filename}`
#echo ${size}
size1=$((${size}-1))
#echo ${size1}
head -c ${size1} ${filename}
I have a test file named as "test". The file includes "123456789" without LF character 0x0A.
# hd test
00000000 31 32 33 34 35 36 37 38 39 |123456789|
00000009
# cat test
123456789
# ./head-1.sh test
12345678
You can use dd instead of head, in case of parsing binary files.