How to check if a variable is set in Bash?
Asked 07 September, 2021
Viewed 2.5K times
  • 58
Votes

How do I know if a variable is set in Bash?

For example, how do I check if the user gave the first parameter to a function?

function a {
    # if $1 is set ?
}

30 Answer