LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   view parts of file by offset (how to use a command such as head -c to start later) (https://www.linuxquestions.org/questions/linux-general-1/view-parts-of-file-by-offset-how-to-use-a-command-such-as-head-c-to-start-later-748880/)

doug23 08-19-2009 07:34 PM

view parts of file by offset (how to use a command such as head -c to start later)
 
I am trying to figure out which character is creating a problem for another program (back in windows).

I get an error that there is an "Invalid character in the given encoding. Line 2, position 2841914. The 40mb file only has two lines (first line only has a few characters, second has almost all), as all of the new line separators were removed from the file.

I am used to being able to use a command such as 'head -c K filename.txt' to view a part of the file, but how do i tell head to start reading the file instead at line 2, position 2841914?

Thanks!
Doug

w1k0 08-19-2009 07:50 PM

tail -c +2841915 filename.txt

doug23 08-19-2009 07:57 PM

Quote:

Originally Posted by w1k0 (Post 3650217)
tail -c +2841915 filename.txt

the first part worked great thanks!!!

Now, for the part I didn't ask:

turns out there are some truly invalid characters: part of the line shows up as 26 04 then two question marks with black backgrounds a letter E, error question mark, T, then another error question mark, and then a \.

Is there any way to replace (regular expression I assume) these error characters?

So, convert "26 04??E?T?\" to "26 04000000"?

Thanks again

micxz 08-19-2009 08:03 PM

How about "cat filename.txt | head -c2 | cut -b2841914-2841915"?

doug23 08-19-2009 08:17 PM

Quote:

Originally Posted by micxz (Post 3650233)
How about "cat filename.txt | head -c2 | cut -b2841914-2841915"?

Unfortunately that did not work.

doug23 08-19-2009 08:18 PM

please note that I will also need to remove the "\" in addition to the illegal characters.

allend 08-20-2009 02:44 AM

Perhaps not elegant, but you can always use a hex editor such as hexedit or bpe or mc or khexedit or okteta or ...


All times are GMT -5. The time now is 10:52 PM.