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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Convert a tab delimited/variable length file to fixed length file Everton_Silveir UNIX for Dummies Questions & Answers 2 12-19-2008 06:21 PM
What the command to find out the record length of a fixed length file? tranq01 UNIX for Dummies Questions & Answers 9 12-04-2008 04:04 PM
Fixed Length records- Korne Shell Program. nrajesh_2009 Shell Programming and Scripting 4 04-11-2007 12:41 PM
fixed record length george_ Shell Programming and Scripting 16 03-28-2006 06:41 AM
creating a fixed length output from a variable length input r1500 Shell Programming and Scripting 2 12-03-2003 01:09 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 08-20-2009
methyl methyl is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 1,184
awk to extract incorrect fixed length records

I have a number of unix text files containing fixed-length records (normal unix linefeed terminator) where I need to find odd records which are an incorrect length.
The data is not validated and records can contain odd backslash characters and control characters which makes them awkward to process in shell. Files are unlikely to exceed 1000 records, so efficiency is not important. Each file has a different fixed length record size.

I am looking for an awk program which can read the length of the first record of a file, then output only those records which are of a different length to the first record. The program does not need to cater for the first record being wrong.

This post works beautifully, but you need to know the length of the record in advance.

Check length of record
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0