How to check if bash variable defined in script

I need to set a bash environment variable called PURGEIMAGE and take specific actions in my script. For example, if PURGEIMAGE set, then purge images from CDN else just URL. I am going to call my script as PURGEIMAGE=yes ./purgecache.sh url1 url2. So …

I need to set a bash environment variable called PURGEIMAGE and take specific actions in my script. For example, if PURGEIMAGE set, then purge images from CDN else just URL. I am going to call my script as PURGEIMAGE=yes ./purgecache.sh url1 url2. So how do I know if a bash variable set at the CLI and used in my bash script running on Linux or Unix-like systems?

The post How to check if bash variable defined in script appeared first on nixCraft.


Print Share Comment Cite Upload Translate
APA
() » How to check if bash variable defined in script. Retrieved from https://www.truth.cx/2021/01/29/how-to-check-if-bash-variable-defined-in-script/.
MLA
" » How to check if bash variable defined in script." - , https://www.truth.cx/2021/01/29/how-to-check-if-bash-variable-defined-in-script/
HARVARD
» How to check if bash variable defined in script., viewed ,
VANCOUVER
- » How to check if bash variable defined in script. [Internet]. [Accessed ]. Available from: https://www.truth.cx/2021/01/29/how-to-check-if-bash-variable-defined-in-script/
CHICAGO
" » How to check if bash variable defined in script." - Accessed . https://www.truth.cx/2021/01/29/how-to-check-if-bash-variable-defined-in-script/
IEEE
" » How to check if bash variable defined in script." [Online]. Available: https://www.truth.cx/2021/01/29/how-to-check-if-bash-variable-defined-in-script/. [Accessed: ]
Select a language: