SóProvas


ID
608122
Banca
CONSULPLAN
Órgão
Prefeitura de Congonhas - MG
Ano
2010
Provas
Disciplina
Sistemas Operacionais
Assuntos

Qual a sintaxe, para que após a execução com sucesso de um comando, seja executado um segundo comando no Linux Debian?

Alternativas
Comentários
  • Condição de execução
    $ comando1 &&  comando2

    o comando2 será executado após a execução, com sucesso, do comando1.

  • http://www.tecmint.com/chaining-operators-in-linux-with-practical-examples/

     

    1. Ampersand Operator (&)

    The function of ‘&‘ is to make the command run in background. Just type the command followed with a white space and ‘&‘. You can execute more than one command in the background, in a single go.

     

    2. semi-colon Operator (;)

    The semi-colon operator makes it possible to run, several commands in a single go and the execution of command occurs sequentially.

     

    3. AND Operator (&&)

    The AND Operator (&&) would execute the second command only, if the execution of first command SUCCEEDS, i.e., the exit status of the first command is 0. This command is very useful in checking the execution status of last command.

     

    4. OR Operator (||)

    The OR Operator (||) is much like an ‘else‘ statement in programming. The above operator allow you to execute second command only if the execution of first command fails, i.e., the exit status of first command is ‘1‘.

     

    7. PIPE Operator (|)

    This PIPE operator is very useful where the output of first command acts as an input to the second command. For example, pipeline the output of ‘ls -l‘ to ‘less‘ and see the output of the command.