shell-script-pt
[Top][All Lists]
Advanced

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

[no subject]



>From address@hidden Sat Jun 21 00:19:37 2008
Return-Path: <address@hidden>
X-Sender: address@hidden
X-Apparently-To: address@hidden
X-Received: (qmail 87704 invoked from network); 21 Jun 2008 07:19:35 -0000
X-Received: from unknown (69.147.108.200)
  by m56.grp.scd.yahoo.com with QMQP; 21 Jun 2008 07:19:35 -0000
X-Received: from unknown (HELO an-out-0708.google.com) (209.85.132.251)
  by mta1.grp.re1.yahoo.com with SMTP; 21 Jun 2008 07:19:35 -0000
X-Received: by an-out-0708.google.com with SMTP id b8so428944ana.91
        for <address@hidden>; Sat, 21 Jun 2008 00:19:35 -0700 (PDT)
X-Received: by 10.100.190.14 with SMTP id n14mr7196162anf.91.1214032775552;
        Sat, 21 Jun 2008 00:19:35 -0700 (PDT)
X-Received: by 10.151.47.13 with HTTP; Sat, 21 Jun 2008 00:19:35 -0700 (PDT)
Message-ID: <address@hidden>
Date: Sat, 21 Jun 2008 04:19:35 -0300
To: shell-script <address@hidden>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
X-Originating-IP: 209.85.132.251
X-eGroups-Msg-Info: 1:12:0:0:0
From: "Ivan lopes" <address@hidden>
Subject: permutar: a,b, c -- DICAS ?????
X-Yahoo-Group-Post: member; u=235251972; 
y=4c3Ou3nLw0TM4iueMUMZ1PW9tTswgXzPAA4F263nokzfSf5xIg
X-Yahoo-Profile: ivanczar78

permutar a,b,c:

saida: abc acb bac bca cab cba

--------------------------------------%<--------------------------------------
#!/bin/bash

v=eval
e=echo
s=sed
r=( a b c );
_c()
{
        for ((i=0; i<${#r[*]}; i++)); do

                for c in ${r[*]}; do
                        o=$o$c','
                done

                t=$t'{'$($e $o| $s 's/,$//')'}'
                o=''
        done

        $v $e $t |
        $s -r "
s/(${r[0]}${r[0]}${r[0]}|[^${r[0]}]${r[0]}${r[0]}|${r[0]}[^${r[0]}]${r[0]}|${r[0]}${r[0]}[^${r[0]}]|${r[0]}${r[0]}${r[0]})\>//g;
s/(${r[1]}${r[1]}${r[1]}|[^${r[1]}]${r[1]}${r[1]}|${r[1]}[^${r[1]}]${r[1]}|${r[1]}${r[1]}[^${r[1]}]|${r[1]}${r[1]}${r[1]})\>//g;
s/(${r[2]}${r[2]}${r[2]}|[^${r[2]}]${r[2]}${r[2]}|${r[2]}[^${r[2]}]${r[2]}|${r[2]}${r[2]}[^${r[2]}]|${r[2]}${r[2]}${r[2]})\>//g;
"
}

_c| sed 's/\s\+/ /g;s/ //'
--------------------------------------%<--------------------------------------

ou

v=eval; e=echo; s=sed; r=( a b c ); _c() { for ((i=0; i<${#r[*]};
i++)); do for c in ${r[*]}; do o=$o$c','; done; t=$t'{'$($e $o| sed
's/,$//')'}';o='';done; $v $e $t | $s -r "
s/(${r[0]}${r[0]}${r[0]}|[^${r[0]}]${r[0]}${r[0]}|${r[0]}[^${r[0]}]${r[0]}|${r[0]}${r[0]}[^${r[0]}]|${array[0]}${array[0]}${array[0]})\>//g;
s/(${r[1]}${r[1]}${r[1]}|[^${r[1]}]${r[1]}${r[1]}|${r[1]}[^${r[1]}]${r[1]}|${r[1]}${r[1]}[^${r[1]}]|${array[1]}${array[1]}${array[1]})\>//g;
s/(${r[2]}${r[2]}${r[2]}|[^${r[2]}]${r[2]}${r[2]}|${r[2]}[^${r[2]}]${r[2]}|${r[2]}${r[2]}[^${r[2]}]|${array[2]}${array[2]}${array[2]})\>//g;
"; }; _c| $s 's/\s\+/ /g;s/ //'


reply via email to

From: Unknown
[Prev in Thread] Current Thread [Next in Thread]