[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] Teste de string com [[ ]]
From: |
M. Rodrigo Monteiro |
Subject: |
Re: [shell-script] Teste de string com [[ ]] |
Date: |
Fri, 9 Jan 2009 15:16:12 -0300 |
2009/1/9 Eri Ramos Bastos <address@hidden>:
> Seu script deve apontar para /bin/sh ao invés de /bin/bash.
>
> [[]] é específico do Bash e o /bin/sh do Ubuntu é um alias para /bin/dash
>
Devo apontar para o /bin/sh ou para /bin/bash?
Testei com os 2:
# /bin/bash
# [[ "teste" =~ "^[a-z]+[a-z0-9\._]*$" ]] || echo nao
nao
# exit
exit
# /bin/sh
# [[ "teste" =~ "^[a-z]+[a-z0-9\._]*$" ]] || echo nao
/bin/sh: [[: not found
nao
# exit
#
# ls -lha /bin/{sh,bash,dash}
-rwxr-xr-x 1 root root 709K 2008-05-12 15:48 /bin/bash
-rwxr-xr-x 1 root root 86K 2008-06-20 13:07 /bin/dash
lrwxrwxrwx 1 root root 4 2009-01-07 09:14 /bin/sh -> dash
Nenhum dos 2 funcionou como esperado.
Abraços,
Rodrigo.
--
M. Rodrigo Monteiro
address@hidden
"Free as in Freedom, not free as in free beer"
"As we are liberated from our own fear, our presence automatically
liberates others"
Linux User # 403730