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
find and replace javeed7 Shell Programming and Scripting 1 04-02-2008 06:00 AM
find and replace rakshit Shell Programming and Scripting 4 01-23-2008 11:52 PM
find and replace mahabunta UNIX for Dummies Questions & Answers 7 09-21-2006 09:05 AM
find and replace valhutch UNIX for Dummies Questions & Answers 4 07-29-2006 02:20 PM
find and replace vikas_j@hotmail UNIX for Dummies Questions & Answers 3 02-25-2002 01:41 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-27-2001
Registered User
 

Join Date: Nov 2001
Location: India
Posts: 3
Question Find & Replace

I get a text file with 70+ columns (seperated by Tab) and about 10000 rows. The 58th Column is all numbers. But sometimes 58th columns has "/xxx=##" after the numeric data. I want to truncate this string using the script. Any Ideas...
__________________
Gagan
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 11-27-2001
doeboy's Avatar
Registered User
 

Join Date: Oct 2001
Location: Here
Posts: 137
You could use sed to strip that string out of the lines that have it.
Reply With Quote
  #3 (permalink)  
Old 11-27-2001
Registered User
 

Join Date: Nov 2001
Location: India
Posts: 3
Thanks, but the problem is bigger. The string "/xxx=##" exists at many other columns too. Even the string along with the numeric data in 58th column exists at many other places.

e.g. I have row one A B C, row two B A C, row three A A A. And I need to change it to row one A B C, row two B D C, row three A D A. That is where ever there is A in Column two replace with D, leave rest as is.
__________________
Gagan
Reply With Quote
  #4 (permalink)  
Old 11-27-2001
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,356
Use "cut" to split the file into three pieces with the middle piece being the column you want to modify. Then modify it. Then use "paste" to reassemble the three pieces back to a single file.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:40 PM.


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