Re: text substitution in a colum

[email protected]
Newsgroups gmane.editors.sed.user
Message-ID <1797069244.560530.1353957602398.JavaMail.root@sz0115a.emeryville.ca.mail.comcast.net>

Assuming your file name is textfile, this should work: 



sed "s/^\([^    ]*[     ][^     ]*[     ]\)\([0-9].*\)$/\1MY_\2/" textfile 



Between each set of brackets is a single tab character. 

It says to replace any pattern that begins the line with any number of not-tab, 

followed by a single tab, followed by and number of not-tab, followed by a tab, 

followed by a digit, with the match found through the 2nd tab, MY_ and the match for rest of line. 



This is probab ly better solved by using awk. 

----- Original Message -----
From: "MOKRANI Rachid" <[email protected]> 
To: [email protected] 
Sent: Monday, November 26, 2012 7:05:49 AM 
Subject: text substitution in a colum 

Hi, 
  
This is my firts port. 
  
I have a file with colum like this. 
  
Title1    Title2      Title3       Title4 
AA          B            66             D 
BB          DS          7              TT 
VS          FDSE     53             TGF 
BG          F            5               GF 
  
I would like to have with a sed command the following result. Add the 
character MY_ before all numbers in the colum number 3 and preserve the 
title "Title3". All the colums are seaprate by a tab. 
  
Title1    Title2    Title3    Title4 
AA         B         MY_66      D 
BB         DS       MY_7       TT 
VS         FDSE   MY_53      TGF 
BG         F          MY_5       GF 
  
  
  
Many thanks for your help/example. 
  
Regards. 
  
__________________________ 
Avant d'imprimer, pensez à l'environnement ! Please consider the environment before printing ! 
Ce message et toutes ses pièces jointes sont confidentiels et établis à l'intention exclusive de ses destinataires. Toute utilisation non conforme à sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. IFP Energies nouvelles décline toute responsabilité au titre de ce message. This message and any attachments are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. IFP Energies nouvelles should not be liable for this message. 
__________________________ 


[Non-text portions of this message have been removed] 



------------------------------------ 

-- 
Yahoo! Groups Links 





[Non-text portions of this message have been removed]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.