Re: manipulate colum

Thierry Blanc <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
try


sed -r '/.*;.*;.*;.*/!{s|$| ; NA;|}'  your_file

if a line has less than four ';' (semicola), add the NA ...


On 28/03/13 13:52, MOKRANI Rachid wrote:
> Hi,
>
> I have a file with fews colums, like the following (I can have more than
> 3 columns) . Some lines have 2 records (or more), and other 3 records
> (or more).
>
> bug_id ; creation_ts ; State ;
> 9      ; 2013-03-21
> 11     ; 2013-03-21
> 12     ; 2013-03-25  ; Y    ;
> 13     ; 2013-03-25  ; Z    ;
>
> I would like to obtain something like the following with sed command.
>
> bug_id ; creation_ts ; State ;
> 9      ; 2013-03-21  ;  N/A  ;
> 11     ; 2013-03-21  ;  N/A  ;
> 12     ; 2013-03-25  ;   Y   ;
> 13     ; 2013-03-25  ;   Z   ;
>
>
>
> Any help will be really appreciate.
> Best 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.
> __________________________
>
>
> ------------------------------------
>
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.