LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-19-2009, 07:34 PM   #1
doug23
LQ Newbie
 
Registered: Aug 2009
Posts: 18

Rep: Reputation: 0
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
 
Old 08-19-2009, 07:50 PM   #2
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

Rep: Reputation: 234Reputation: 234Reputation: 234
tail -c +2841915 filename.txt
 
Old 08-19-2009, 07:57 PM   #3
doug23
LQ Newbie
 
Registered: Aug 2009
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by w1k0 View Post
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

Last edited by doug23; 08-19-2009 at 08:06 PM.
 
Old 08-19-2009, 08:03 PM   #4
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
How about "cat filename.txt | head -c2 | cut -b2841914-2841915"?
 
Old 08-19-2009, 08:17 PM   #5
doug23
LQ Newbie
 
Registered: Aug 2009
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by micxz View Post
How about "cat filename.txt | head -c2 | cut -b2841914-2841915"?
Unfortunately that did not work.
 
Old 08-19-2009, 08:18 PM   #6
doug23
LQ Newbie
 
Registered: Aug 2009
Posts: 18

Original Poster
Rep: Reputation: 0
please note that I will also need to remove the "\" in addition to the illegal characters.
 
Old 08-20-2009, 02:44 AM   #7
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,376

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any command to know Offset using TimeZone nagendrar Linux - Newbie 3 04-09-2009 03:57 AM
view pdf file through command prompt sumer Linux - Newbie 2 03-31-2009 10:40 AM
Texmaker question: can't start the command to view Pdf amyssal Linux - Newbie 1 01-17-2009 09:17 AM
Any command to view contents of CD image (iso file) ? lawrence_lee_lee Linux - Software 3 10-10-2007 12:38 AM
can i view current HFS parts with linux PPC? icyfire Linux - Software 2 11-10-2002 02:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration