Quantcast
Channel: How to determine if a bash variable is empty? - Server Fault
Viewing all articles
Browse latest Browse all 16

Answer by gluk47 for How to determine if a bash variable is empty?

$
0
0

My 5 cents: there is also a shorter syntax than if ..., this one:

VALUE="${1?"Usage: $0 value"}"

This line will set VALUE if an argument has been supplied and will print an error message prepended with the script line number in case of an error (and will terminate the script execution).

Another example can be found in the abs-guide (search for «Example 10-7»).


Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>