[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RE : Re: [HS] Script bash [RESOLU]



On Tue, Apr 10, 2007 at 05:36:42PM +0200, Tahar wrote:
> Merci beaucoup pour votre aide, en effet awk fais des miracles :)

sauf que pour esperer rentabiliser l'ouverture de awk, j'espere que tu
vas donner a manger a ton script! et bien plus que 6 lignes !

Pour le peu de données que tu as a traiter, je crois au contraire que
dash,mksh,zsh c'est tres bien (pas bash, bash c'est mal!).

ci-dessous un exemple testé avec dash! bonne journée a toi.

Cordialement,
Marc Chantreux 

echo '-rwxrwxr-x  1 wwwrun www 14K Jan 18 17:21 ./ae/aetech-solutions.com/a./a.boughezala/userdb
-rwxrwxr-x  1 wwwrun www 14K Jan 31 08:09 ./ae/aetech-solutions.com/c./c.amri/userdb
-rwxrwxr-x  1 wwwrun www 14K Jan 30 17:59 ./ae/aetech-solutions.com/d./d.chabbah/userdb
-rwxrwxr-x  1 wwwrun www 14K Jan 23 15:56 ./ae/aetech-solutions.com/da/dap/userdb
-rwxrwxr-x  1 wwwrun www 16K Jan 31 08:12 ./ae/aetech-solutions.com/dc/dc1/userdb
-rwxrwxr-x  1 wwwrun www 14K Jan 18 17:22 ./ae/aetech-solutions.com/m./m.boumaiza/userdb' |
while IFS=/ read rien rien2 domain rien3 login reste; do echo $login@$domain; done

echo ' 
    AUTREMENT
' 

echo '-rwxrwxr-x  1 wwwrun www 14K Jan 18 17:21 ./ae/aetech-solutions.com/a./a.boughezala/userdb
-rwxrwxr-x  1 wwwrun www 14K Jan 31 08:09 ./ae/aetech-solutions.com/c./c.amri/userdb
-rwxrwxr-x  1 wwwrun www 14K Jan 30 17:59 ./ae/aetech-solutions.com/d./d.chabbah/userdb
-rwxrwxr-x  1 wwwrun www 14K Jan 23 15:56 ./ae/aetech-solutions.com/da/dap/userdb
-rwxrwxr-x  1 wwwrun www 16K Jan 31 08:12 ./ae/aetech-solutions.com/dc/dc1/userdb
-rwxrwxr-x  1 wwwrun www 14K Jan 18 17:22 ./ae/aetech-solutions.com/m./m.boumaiza/userdb' |
while read line; do
    # login=${line%/*}
    # login=${#login#*/}

    # chercher l'avant-dernier champ
    login=${line%/*}
    # virer */ au debut de la chaine
    login=${login##*/}

    # meme principe ! 
    domain=${line#*/*/}
    domain=${domain%%/*}

    echo $login@$domain
done











Reply to: