You can test the success if a command directly using the shell keyword while, until, and if or with the control operator && and ||. The exit code is stored un the special parameter $?.
If the command executed successfully (or true), the value of $? is zero. If the command failed for some reason, $? will contain a positive integer between 1 and 255. For me this is confused because in Boolean Algebra 1 is true and 0 is false :-S
A failed command usually return 1. Zero and nonzero exit codes are also known as true and false, respectively.
With and example is better
$printf "%v\n" bash: printf: `v': carácter de formato inválido $echo $? 1
This example shows the mentioned before.
Etiquetas: GNU/Linux, nero linux, Ubuntu, Utilidades