Re: count in colum

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

cut -d ';' -f 1 your_file | uniq -c | sed -r 's|\s*([0-9]*) 
([0-9]*)|\2;\1;|'

sed can't count, so use uniq to do the counting.

On 29/03/13 14:43, MOKRANI Rachid wrote:
> Hi,
>
> Someone can give me a simple sed commande for doing the following.
>
> My file .
>   
> Num ; Count ;
> 8 ; 1 ;
> 9 ; 1 ;
> 9 ; 1 ;
> 9 ; 1 ;
> 10 ; 1 ;
> 10 ; 1 ;
> 10 ; 1 ;
> 11 ; 1 ;
> 12 ; 1 ;
> 12 ; 1 ;
>
> I would like the following result with sed.
>
> Num ; Count ;
> 8 ; 1 ;
> 9 ; 3 ;
> 10 ; 3 ;
> 11 ; 1 ;
> 12 ; 2 ;
>
> 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.