Executando múltiplos comandos de uma vez só

Categoria: Linux Ubuntu
Publicado em 13 de Setembro de 2014

The three commands in the following example will all execute even if the ones preceding them fail:

1
$ make ; make install ; make clean

However, you may want to abort subsequent commands if one fails. You can do this using the && (and) operator as in:

1
$ make && make install && make clean

If the first command fails the second one will never be executed. A final refinement is to use the || (or) operator as in:

1
$ cat file1 || cat file2 || cat file3

In this case, you proceed until something succeeds and then you stop executing any further steps.

 

Copyright © Fernando Hidemi Uchiyama 2010 - Todos os direitos reservados