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
Help with Fixed width File Parsing sate911 UNIX Desktop for Dummies Questions & Answers 4 05-19-2008 08:18 AM
Extracting records with unique fields from a fixed width txt file sitney Shell Programming and Scripting 8 02-09-2008 11:18 PM
Converting field into fixed width csv videsh77 UNIX for Advanced & Expert Users 1 11-02-2007 01:30 PM
adding delimiter to a fixed width file sumeet Shell Programming and Scripting 2 03-21-2007 06:19 AM
Fixed Width file using AWK alok.benjwal UNIX for Dummies Questions & Answers 2 12-05-2005 07:39 AM

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

Join Date: Jul 2006
Posts: 183
Stumble this Post!
Changing particular field in fixed width file

I have a fixed width file and i need to change 36th field to "G" in for about random 20 records? How can I do it?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-11-2008
sysgate's Avatar
Unix based
 

Join Date: Nov 2006
Location: /root
Posts: 1,160
Stumble this Post!
Since I'm not sure what exactly you mean, here's a list of sed-one-liners, I hope you'll find what you looking for.
Reply With Quote
  #3 (permalink)  
Old 02-11-2008
Registered User
 

Join Date: Jun 2006
Posts: 74
Stumble this Post!
sed '4,6 s/\(.\{35\}\)./\1G/' temp.txt>sample.txt

This will modify the 36th character from line number 4-6 (u can modify it for 20 lines)

hope this helps
Reply With Quote
  #4 (permalink)  
Old 02-11-2008
Registered User
 

Join Date: Jul 2006
Posts: 183
Stumble this Post!
can you let me know where i should give the character to what it needs to be modifed too.
Reply With Quote
  #5 (permalink)  
Old 02-11-2008
Registered User
 

Join Date: Jun 2006
Posts: 74
Stumble this Post!
sed '4,6 s/\(.\{35\}\)./\1G/' temp.txt>sample.txt

change the value of G to the one u want
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




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