De acordo com as Leis 12.965/2014 e 13.709/2018, que regulam o uso da Internet e o tratamento de dados pessoais no Brasil, ao me inscrever na newsletter do portal DICAS-L, autorizo o envio de notificações por e-mail ou outros meios e declaro estar ciente e concordar com seus Termos de Uso e Política de Privacidade.
Colaboração: Rubens Queiroz de Almeida
Data de Publicação: 30 de Maio de 1997
A partir de hoje serão veiculadas algumas dicas sobre variáveis em Shell scripts juntamente com exemplos de utilização. Começaremos com os argumentos passados na linha de comandos. Estes argumentos recebem o nome de variáveis posicionais e são identificadas por $0, $1, $2, ...
A variável $0 indica o comando emitido. Por exemplo, no comando
% ls a b c d
a variável $0 assume o valor "ls". A variável $1 recebe o valor "a", a variável $2 recebe o valor "b" e assim por diante.
Esta variável é bastante utilizada para se enviar avisos ao usuário quanto à sintaxe correta de uso de comandos. Por exemplo:
echo "Sintaxe: $0 arquivo_entrada arquivo_saida"
Se a linha acima se encontrasse em uma shell script chamada "chname" e a invocassemos sem especificar corretamente seus argumentos, receberiamos o seguinte aviso:
Sintaxe: chname arquivo_entrada arquivo_saida
l. Jam miniature marshmallows up your nose and sneeze them out. See how many you can do at a time.
2. Use your Mastercard to pay your Visa, and vice-versa.
3. Pop some popcorn without putting the lid on.
4. When someone says "Have a nice day", tell them you have other plans.
5. Make a list of things to do that you have already done.
6. Dance naked in front of your pets.
7. Put your toddler's clothes on backwards and send him to pre-school as if nothing is wrong.
8. Fill out your tax form using Roman Numerals.
9. Tape pictures of your boss on watermelons and launch them from high places.
10. Leaf through "National Geographic" and draw underwear on the natives.
11. Tattoo "Out to Lunch" on your forehead.
12. Go shopping. Buy everything. Sweat in it. Return it the next day.
13. Buy a subscription to "Sleazoid Weekly" and send it to your boss's husband/wife.
14. Pay your electric bill in pennies.
15. Drive to work in reverse.
16. Find out what a frog in a blender really looks like.
17. Tell your boss to "blow it out your mule", and let him figure it out.
18. Sit naked on a shelled hard-boiled egg.
19. Polish your car with earwax.
20. Read the dictionary upside down and look for secret messages.
21. Start a nasty rumor and see if you recognize it when it comes back to you.
22. Braid the hairs in each nostril.
23. Write a short story using alphabet soup.
24. Stare at people through the tines of a fork and pretend they're in jail.
25. Make a language up and ask people for directions in it.
Bonus: Replace the filling of a Twinkie with ketchup and put it back in the wrapper.
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Comentários