| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

if

Page history last edited by PBworks 17 years, 2 months ago

if

Testa condições para execução seletiva de ações ou comandos

 

   # testa se o usuário é root
   # != significa diferente


   if [ "$USR" != "root" ]; then
     echo '  Você não é root!'
   fi


   # testa se uma pasta existe
   if [ ! -d ~/bin ]; then
      mkdir ~/bin
   fi
   cd ~/bin

Obs: a exclamação é uma negação:
  
      ! -d  = (se não existe o diretório ~/bin)


Outro modo de testar se uma pasta existe
  
      [ -d ~/bin ] || mkdir ~/bin ; cd ~/bin

Comments (0)

You don't have permission to comment on this page.