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
how to convert Fixed length file to delimited file. satyam_sat Shell Programming and Scripting 7 04-02-2008 11:41 PM
What the command to find out the record length of a fixed length file? tranq01 UNIX for Dummies Questions & Answers 3 10-19-2007 11:16 AM
use SQL loader to dump a fixed length file in to DB anumkoshy Shell Programming and Scripting 2 10-10-2007 02:53 AM
convert XML file into Text file(fixed length) ram2s2001 Shell Programming and Scripting 0 11-02-2005 09:28 PM
creating a fixed length output from a variable length input r1500 Shell Programming and Scripting 2 12-03-2003 09:09 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-31-2008
Registered User
 

Join Date: Mar 2008
Posts: 3
Stumble this Post!
Question Manipulating a fixed length file w/o PERL

Greetings,

I need to take a fixed length file, similar to the following:

<input file>

1233 e 612 i
43378 f 03 x
22 17 e 9899
a 323e a6 z7

read in the character in position 6, and if that character = e, delete that line from the file.

<output file>

43378 f 03 x
22 17 e 9899

and if possible, output the deleted lines to a new "log" file.

<log file>

1233 e 612 i
a 323e a6 z7

The old file must maintain its structure, the log file wouldn't.

I'm on an AIX platform, and have sh/ksh/bash available to script in.
I'm sure it can be done with some combination of cut/sed/awk, I just haven't been able to get it right as of yet. Any help would be greatly appreciated!

Thanks in advance.
DB
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-31-2008
aigles's Avatar
Registered User
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,211
Stumble this Post!
sed solution(s) :
Code:
sed '/^.....e/d' inputfile
sed /^.\{5\}e/d' inputfile
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 03-31-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
Stumble this Post!
Also note the w command in sed for writing stuff to a named file.

You don't really need sed, though.

Code:
grep ^.....e >ditch
grep -v ^.....e >keep
Reply With Quote
  #4 (permalink)  
Old 03-31-2008
Registered User
 

Join Date: Mar 2008
Posts: 3
Stumble this Post!
Excellent

Thank you Jean-Pierre, that works great, much appreciated!

-DB
Reply With Quote
  #5 (permalink)  
Old 03-31-2008
Registered User
 

Join Date: Mar 2008
Posts: 3
Stumble this Post!
I'll check out the grep solution as well

Thank you Era!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:47 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