Re: split column
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <CAEE75_3mNNc=2myD_tW9geuUEp1MLULpWSgW_rcV0wHeGQWCnw@mail.gmail.com> |
sed -E 's/(([^;]*;){6} *[0-9]*) ?/\1;/' should do it.
On Tue, Mar 29, 2016 at 2:48 AM, Thierry Blanc [email protected]
[sed-users] <[email protected]> wrote:
>
>
> ugly, but should work:
>
> sed 's|;|\n|g' ff|sed -r 'n;n;n;n;n;s|([0-9 ]*)([ A-Za-z]*)|\1;\2|;n;n'
> | sed 'N;N;N;N;N;N;N;s|\n|;|g'
>
> what about non alphanumerical signs like %^&*#?
>
>
> On 29/03/16 09:48, MOKRANI Rachid [email protected] [sed-users]
> wrote:
> > Hi,
> >
> > Do you have a simple proposal with sed / awk.
> >
> > In this exemple, need to split column 7
> >
> > Company A ; NAME A ; FIRSTNAME 1 ; JOB 1 ; Town 1 ; 145854 abVFrd ;
> COMMENT 1 ;
> >
> >
> >
> > And obtain 8 columns (7 always a number - 8 always alphabetic)
> >
> > Company A ; NAME A ; FIRSTNAME 1 ; JOB 1 ; Town 1 ; 145854 ; abVFrd ;
> COMMENT 1 ;
> >
> >
> >
> > But sometime the colum 7 can have
> > ; 145854 abVFrd ;
> > Need to have
> > ; 145854 ; abVFrd;
> >
> > ; 145854;
> > Need to have
> > ; 145854; ;
> >
> >
> > ; abVFrd;
> > Need to have
> > ; ; abVFrd;
> >
> >
> > ; ;
> > Need to have
> > ; ; ;
> >
> >
> >
> >
> >
> > Company A;NAME A;FIRSTNAME 1;JOB 1;Town 1; 145854 abVFrd;COMMENT 1;
> >
> > Company A;NAME A;FIRSTNAME 4;JOB 1;Town ;145862 dsfsd; COMMENT 5;
> >
> > Company B;NAME T ;FIRSTNAME 1;JOB 2;Town 2;ABGHKYH; COMMENT 1235;
> >
> > Company C;NAME M;FIRSTNAME 2;JOB 7;Town 1;259874; COMMENT 4;
> >
> > Company Y;NAME G;FIRSTNAME 4;JOB 52;Town 1;; COMMENT 1;
> >
> > Company Y;NAME F ;FIRSTNAME 8;JOB 82;Town 3;125478; COMMENT 15;
> >
> >
> >
> > Need to obtain the result below.
> >
> >
> >
> > Company A;NAME A;FIRSTNAME 1;JOB 1;Town 1; 145854;abVFrd;COMMENT 1;
> >
> > Company A;NAME A;FIRSTNAME 4;JOB 1;Town ;145862;dsfsd; COMMENT 5;
> >
> > Company B;NAME T ;FIRSTNAME 1;JOB 2;Town 2;;ABGHKYH; COMMENT 1235;
> >
> > Company C;NAME M;FIRSTNAME 2;JOB 7;Town 1;259874;; COMMENT 4;
> >
> > Company Y;NAME G;FIRSTNAME 4;JOB 52;Town 1;;; COMMENT 1;
> >
> > Company Y;NAME F ;FIRSTNAME 8;JOB 82;Town 3;125478;; COMMENT 15;
> >
> >
> >
> > Thanks,
> > 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.
> > __________________________
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> > ------------------------------------
> > Posted by: MOKRANI Rachid <[email protected]>
> > ------------------------------------
> >
>
>
>
[Non-text portions of this message have been removed]