Le Monday 08 August 2005 18:44, Christophe Gaubert a écrit :
> Le Lundi 8 Août 2005 18:32, Jean-Claude Garaud a écrit :
> > Effectivement, c'est une solution. Mais en fait je me demandais s'il
> > était possible de faire ça en une seule commande.
>
> Tu es exigeant ! ;) On peut le faire mais est-ce vraiment lisible ?
>
> a="abcdtotodefgtotohij"
> cherche="toto"
> echo $(( `expr length ${a%%$cherche*}` + 1 ))

Tiens, à propos de expr et des "" :
a="abcd totodefgtotohij"                                                        
        # un espace avant toto
echo $(( `expr length ${a%%$cherche*}` + 1 ))
5                                                                               
                # faux !
echo $(( `expr length "${a%%$cherche*}"` + 1 ))
6                                                                               
                # exact

Jean-Claude



____________________________________________________
Want to buy your Pack or Services from Mandriva? 
Go to http://store.mandriva.com
Join the Club : http://www.mandrivaclub.com
____________________________________________________

Répondre à