![]() |
Pages (5): « 1 [2] 3 4 5 » Show 150 posts per page |
.dsy:it. (http://www.dsy.it/forum/)
- Tech (http://www.dsy.it/forum/forumdisplay.php?forumid=189)
-- [Misteri] -e si nasconde (http://www.dsy.it/forum/showthread.php?threadid=21078)
Ah ultima cosa lally se il problema e' proprio "stampare SOLO -e " ho una soluzione anche se non e' il massimo 
__________________
(\ /)
( . .)
c('')('') This is Bunny!
Help her succeed in world domination by copy and pasting her in
your signature.
tipo?
io semplicemente facevo un
if echo $variabile | grep <regexp>
then
command
else
command
fi
boh mi sembrava la soluzione +semplice... :\
si può adattare?
__________________
*** Proposta di legge di iniziativa popolare: "8x1000 ALLA RICERCA"
Informati e firma la petizione! E' nel tuo interesse! ![]()
*** Browse my dA gallery !
***In medio stat virtus
Originally posted by lallyblue
tipo?
io semplicemente facevo un
if echo $variabile | grep <regexp>
then
command
else
command
fi
boh mi sembrava la soluzione +semplice... :\
si può adattare?
case "$variabile" in
"-e"|"-q"|"-u"|"-uq")
command1
command2
;;
*)
command3
;;
esac

__________________
(\ /)
( . .)
c('')('') This is Bunny!
Help her succeed in world domination by copy and pasting her in
your signature.
Originally posted by ak47
la RE che soddisfa la tua richiesta è [-e|-q|-ue|-uq]
code:
egrep "(^-)(e|q|ue|uq)"
__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~
l'opzione purtroppo non posso cambiarla, è quella che devo passare ad un programma x avere un certo risultato.
a questo punto userò l'egrep che mi hai suggerito, solo mi suonava strano che un comando come echo avesse tali limitazioni...
non c'è un comando alternativo all'echo x mostrare il contenuto delle variabili, vero?
__________________
*** Proposta di legge di iniziativa popolare: "8x1000 ALLA RICERCA"
Informati e firma la petizione! E' nel tuo interesse! ![]()
*** Browse my dA gallery !
***In medio stat virtus
Originally posted by DeepBlue
in bash con *grep mi sa che così non funziona.
Meglio che passi tutto a egrep così:
code:
egrep "(^-)(e|q|ue|uq)"

__________________
(\ /)
( . .)
c('')('') This is Bunny!
Help her succeed in world domination by copy and pasting her in
your signature.
beh perché di solito il case lo applico quando ho tante opzioni e diventerebbe difficile usare tanti if/then/else in cascata. visto che qui o l'opzione è tra quelle 4 (e allora esegue il comando) oppure è qualsiasi altra cosa (e allora stampa un mex d'errore) mi sembrava + logico usare un if/then/else... ma non sono una buona programmatrice quindi è facile che mi sbagli... ![]()
__________________
*** Proposta di legge di iniziativa popolare: "8x1000 ALLA RICERCA"
Informati e firma la petizione! E' nel tuo interesse! ![]()
*** Browse my dA gallery !
***In medio stat virtus
Originally posted by lallyblue
non c'è un comando alternativo all'echo x mostrare il contenuto delle variabili, vero?
Originally posted by Alf
ma scusa ... fare un if in pipe a un egrep e' simulare un case ... O_o;; perche' simularlo quando c'e' ?!
__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~
Originally posted by lallyblue
beh perché di solito il case lo applico quando ho tante opzioni e diventerebbe difficile usare tanti if/then/else in cascata. visto che qui o l'opzione è tra quelle 4 (e allora esegue il comando) oppure è qualsiasi altra cosa (e allora stampa un mex d'errore) mi sembrava + logico usare un if/then/else... ma non sono una buona programmatrice quindi è facile che mi sbagli...![]()



__________________
(\ /)
( . .)
c('')('') This is Bunny!
Help her succeed in world domination by copy and pasting her in
your signature.
fico... ![]()
grazie mille cmq!
__________________
*** Proposta di legge di iniziativa popolare: "8x1000 ALLA RICERCA"
Informati e firma la petizione! E' nel tuo interesse! ![]()
*** Browse my dA gallery !
***In medio stat virtus
Originally posted by lallyblue
fico...
grazie mille cmq!
code:
pippo=-e printf "%s\n" $pippo
__________________
(\ /)
( . .)
c('')('') This is Bunny!
Help her succeed in world domination by copy and pasting her in
your signature.
grande Alf ![]()
__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~
Senza diventare matti, c'e' getopts per fare cio':
Nell'esempio lo script accetta le opzioni -h -a -b -c
code:
while getopts "habc" opt; do case $opt in h ) visualizzo_help ;; a) eseguo_una_cosa;; b ) faccio_altra_cosa;; .... esac done
__________________
When once you have tasted flight, you will walk the earth, forever more, with your eyes turned skyward. For there you have been, and there you long to return.
“Dovere, tempo, destino, tutto tende a separarci e, di fatto, ci separa. Ma il sentimento non conosce frontiere e mi unisce a te come se avessi sempre la mia mano sulla tua"
In ogni caso, per controllare su una stringa e' uguale a un'altra, si usa if test:
in questo caso voglio che lo script dice gatto se lanciato con -e
code:
if test $1 = "-e"; then echo "gatto"; fi
__________________
When once you have tasted flight, you will walk the earth, forever more, with your eyes turned skyward. For there you have been, and there you long to return.
“Dovere, tempo, destino, tutto tende a separarci e, di fatto, ci separa. Ma il sentimento non conosce frontiere e mi unisce a te come se avessi sempre la mia mano sulla tua"
Originally posted by Viry
Senza diventare matti, c'e' getopts per fare cio':
Nell'esempio lo script accetta le opzioni -h -a -b -c
code:
while getopts "habc" opt; do case $opt in h ) visualizzo_help ;; a) eseguo_una_cosa;; b ) faccio_altra_cosa;; .... esac done


__________________
*** Proposta di legge di iniziativa popolare: "8x1000 ALLA RICERCA"
Informati e firma la petizione! E' nel tuo interesse! ![]()
*** Browse my dA gallery !
***In medio stat virtus
| All times are GMT. The time now is 14:51. | Pages (5): « 1 [2] 3 4 5 » Show all 68 posts from this thread on one page |
Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.