Haraball.no

Check the result of a linux command

2016-09-05

If you need to check the result of a linux command, you can append echo $? at the end of the line. The output is 0 for success and 1 for an error.

Ex:

You need to test if a folder exists:

$ test -d exists/; echo $?
0
$ test -d dontexist/; echo $?
1