Testing for non-zero length string in ksh
Issue
-
How to check whether the length of the string in the file is zero or non-zero in ksh?
-
We have a ksh script that runs PROGRAM1 and writes its exit code to a file.
-
We would like to implement a subsequent operation (PROGARM2) being performed after PROGRAM1 only when the file has some non-zero value which represents the exit code of PROGRAM1.
-
If the file has zero length value (which means the file is empty), the subsequent operation (PROGRAM2) shouldn't be performed.
Environment
- Red Hat Enterprise Linux 5
- Red Hat Enterprise Linux 6
- ksh
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
