Sponsored Content
Full Discussion: If - else
Top Forums Shell Programming and Scripting If - else Post 303021163 by Don Cragun on Sunday 5th of August 2018 07:04:18 PM
Old 08-05-2018
Redirecting to a file and setting a variable are two very different things. Redirecting output to a file named a does not in any way affect the current value of a variable named a and does not create a variable named a if it did not already exist.

Since we have to assume that you have shown us everything that we need to know to figure out how your script works, all we can say is that:
Code:
[ "$a" -ne 0 ]

will give you a syntax error since a variable that has not been assigned a value does not have a numeric value (unless a was set somewhere else and exported into your environment before your script was started) and the if containing the above test will always evaluate to false.
 
All times are GMT -4. The time now is 12:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy