How to determine whether a variable is empty in shell In shell programming, the error checking items for parameters include whether the variable is assigned a value (that is, whether a variable is empty). The method to determine whether a variable is empty is as follows: 1. Variables are enclosed in " " quotes #!/bin/sh para1= if [ ! -n "$para1" ]; then echo "IS NULL" else echo "NOT NULL" fi [Output result] "IS NULL" 2. Judge directly by variables #!/bin/sh para1= if [ ! $para1 ]; then echo "IS NULL" else echo "NOT NULL" fi [Output result] "IS NULL" 3. Use test to judge #!/bin/sh dmin= if test -z "$dmin" then echo "dmin is not set!" else echo "dmin is set !" fi 【Output result】"dmin is not set!" 4. Use "" to judge #!/bin/sh dmin= if [ "$dmin" = "" ] then echo "dmin is not set!" else echo "dmin is set !" fi 【Output result】"dmin is not set!" You may also be interested in:
|
<<: How to use regular expression query in MySql
>>: A brief talk about the knowledge you need to master when getting started with Vue
Scenario A recent requirement is an h5 page for m...
Table of contents 1. Installation 2. Import in ma...
Vue card flip carousel display, while switching d...
Preface Sometimes when hover pseudo-class adds a ...
reduce method is an array iteration method. Unlik...
Table of contents 1. Two-way binding 2. Will the ...
1. MySQL User Management [Example 1.1] Log in to ...
1. In addition to the default port 8080, we try t...
Table of contents origin Environmental Informatio...
Underlining in HTML used to be a matter of enclos...
Table of contents 1. What is Ts 2. Basic Grammar ...
Detailed explanation and examples of database acc...
Introduction Do you really know the difference be...
I have been quite free recently. I have been doin...
Preface Regarding the use of MySQL indexes, we ha...