The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Splitting a file based on the records in another file er_ashu Shell Programming and Scripting 2 05-12-2008 01:34 PM
How to check for a valid numeric input Vijayakumarpc Shell Programming and Scripting 1 08-04-2007 05:34 AM
Count No of Records in File without counting Header and Trailer Records guiguy Shell Programming and Scripting 2 06-07-2007 09:15 AM
Script to check for a file, check for 2hrs. then quit mmarsh UNIX for Dummies Questions & Answers 2 09-16-2005 11:46 AM
renaming files in one commend fboisvert UNIX for Dummies Questions & Answers 2 09-12-2001 10:21 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-17-2008
Registered User
 

Join Date: May 2008
Posts: 2
Check valid records in really big file with one commend..

Hi,
I have a 5 gig file, no record terminators, field terminators are newline. The record length is 768 and I would like to check that every 768th byte is a newline and print out the byte position if it isn't. I would like to do this going either forward or backwards with one command if possible. I read that awk has a 3000 byte limit for a record so maybe a complex grep?

Thanks,

Victor
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-18-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,094
Many egreps will probably choke on this, but it's worth a try.

Code:
egrep -v '^.{768}$' file
Reply With Quote
  #3 (permalink)  
Old 05-18-2008
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 462
Maybe awk will help.
Code:
awk '{len=length($0); if(len < 768) {print NR, len}}' data.file
Reply With Quote
  #4 (permalink)  
Old 05-18-2008
Registered User
 

Join Date: May 2008
Posts: 2
thanks for the suggestions, I'll try them tomorrow..
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0