LinuxQuestions.org
Review your favorite Linux distribution.
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 09-24-2010, 03:29 PM   #1
edspyhill01
LQ Newbie
 
Registered: Sep 2010
Posts: 3

Rep: Reputation: 0
Command to get past an I/O error in a file?


I have a log file that has an I/O Error about halfway in. It is a syslog file with Sendmail log entries. I need to break into smaller files.

I tried using a simple egrep command creating new files by the date _egrep "^Sep 19" filename_ but the command hangs when it hits the I/O Error.

I tried split but it bails out when it hits the I/O Error.

Is there anyway to read the file and get past the I/O Error?
IS there a way to read the file from the bottom up so I can get the data from the top and bottom?

Ed
 
Old 09-24-2010, 03:39 PM   #2
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
Are you able to track down which line the I/O error is on? Something like the following should work:

Code:
while read line; do echo ${line}; done < FILE
Regards,

Alunduil
 
Old 09-24-2010, 04:04 PM   #3
edspyhill01
LQ Newbie
 
Registered: Sep 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by alunduil View Post
Are you able to track down which line the I/O error is on? Something like the following should work:

Code:
while read line; do echo ${line}; done < FILE
Regards,

Alunduil
Running the command now. The file has about 340,000 lines. I'll update this reply when the error pops up.

Ed

The read command just stops without any message at the I/O Error. I don't think I can get beyond the error in the file.

Ed

Last edited by edspyhill01; 09-24-2010 at 10:17 PM. Reason: Update & command output
 
Old 09-25-2010, 12:03 AM   #4
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 350

Rep: Reputation: 159Reputation: 159
Try copying the file with dd.
This should omit any unreadable blocks from the output:
Code:
dd if=infilename of=outfilename conv=noerror
From http://www.linuxquestions.org/linux/...ything_With_DD
Quote:
noerror
Does not stop processing on an input error. When an input error occurs, a diagnostic message is written on standard error, followed by the current input and output block counts in the same format as used at completion. If the sync conversion is specified, the missing input is replaced with null bytes and processed normally. Otherwise, the input block will be omitted from the output.
 
Old 09-26-2010, 11:07 PM   #5
edspyhill01
LQ Newbie
 
Registered: Sep 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Kenhelm View Post
Try copying the file with dd.
This should omit any unreadable blocks from the output:
Code:
dd if=infilename of=outfilename conv=noerror
From http://www.linuxquestions.org/linux/...ything_With_DD
Tried using dd command with noerror and I still can't get past the I/O Error.

Kludge solution:
I did a tail of the file and increased the line number until the command failed, then I decreased the line number until the tail command succeeded. I lost some data but retrieved most of it.

Thanks all for your help.

Ed
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] cannot get past grub error 22 rip Linux - General 9 11-07-2009 03:15 PM
Ubuntu wont boot past black command type screen aconversi Linux - Newbie 10 06-13-2009 03:45 PM
how to copy-past on command line? jameshao Linux - Newbie 5 02-01-2009 04:55 PM
Problems loading Mandriva past command prompt parables Linux - Newbie 2 03-18-2008 01:50 PM
Random file lines directed to a new file. In script an error. In command line no err leventis Programming 1 09-28-2006 08:16 AM

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

All times are GMT -5. The time now is 09:36 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration