Bash: Error: -eq: unary operator expected

You may have received this error: -eq: unary operator expected, or a similiar error. The issue in most cases is that you probably haven’t initialized the variable before checking for its value, which happens if you have loops or redirects which miss the initialization.

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.