How to check exit status of a command line in BASH ?
$? Operator gives the exit status code
To check the exit status in bash, you can user the specific operator $?, for example here, we check if there is an ldaps server(not ldap but ldaps !!!)
Next we define, the exit STATUS using operator $?:
STATUS equal to 0 means a success (failure if different to 0). In our case, string ldaps is not in {ldap.conf}, it is a failure.
If you found this post or this website helpful and would like to support our work, please consider making a donation. Thank you!
Help UsArticles in the same category
- Trouver rapidement et facilement l'adresse mac courante sous Linux
- How to Get or Extract filename and extension in bash
- How to check exit status of a command line in BASH ?
- Fast and easy way to get mac address on Linux
- Error "standard in must be a tty" when doing ssh username@server 'sudo command'
- Disable the usage of history using HISTSIZE,HISTFILE
- Désactiver l'historique en utilisant HISTSIZE,HISTFILE
- Comment vérifier le statut d'exécution d'une commande en BASH ?
- Comment extraire le nom et l'extension d'un fichier en Bash
- Back to previous directory in shell cd,$OLDPWD
- Linux Bash