The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-27-2007
DarkHound DarkHound is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 3
replacing a nul field with text

Ok here's my pickle. I have a file in which every line must be the same length. Each field within the line is a certain length. None of these can be changed. What I need to do is look at a specific field within this file, let's say it starts with character 30 and ends with 50. If this field is empty, I need it to be replaced with a bit of text.

An example. Note that field 3 below in the first line is blank. I need to make it look like line2. Also, it should ignore the line if there is anything at all in the field as in line 2 and 3.

Code:
field1field2                       field4
field1field2field3                field4
field1field2sometext           field4

Any help would be appreciated as I'm horrible with sed.

Last edited by DarkHound; 08-27-2007 at 09:41 AM.. Reason: Wanted to fix offsets, apparently the board [code] tags do not use monospaced fonts.