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



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
need help with replacing a certain field... shennanigan83 Shell Programming and Scripting 5 04-09-2008 02:00 AM
Replacing text chrchcol Shell Programming and Scripting 3 07-25-2006 01:30 PM
Replacing certain field charbel Shell Programming and Scripting 1 04-26-2006 05:00 PM
replacing text ajaya Shell Programming and Scripting 2 04-12-2006 01:31 PM
Replacing the last field of a line. Darek Shell Programming and Scripting 3 08-19-2005 12:45 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-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.
 

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 11:07 PM.


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