I have a file which contain 64895 characters
In [95]: !wc -c 07.org
64895 07.org
How could I get the character at position 60000?
I have a file which contain 64895 characters
In [95]: !wc -c 07.org
64895 07.org
How could I get the character at position 60000?
If the file has newlines, then
head
andtail
can be used to find a specific byte. For a file of ascii characters, chars are equivalent to bytes, but non-ascii unicode characters occupy multiple bytes. Also, the newline characters are counted. To get the byte at position 60000:To see how this works, the following loop looks at the first 9 bytes:
Bytes 4 and 7 are newline characters.
There is the
cut
command for that:The 1st part removes newlines; the 2nd part then prints the 60000th char (but does skip the newline char so if those need to be included in the count towards 60000 this wont work ;) )