Testing for non-zero length string in ksh

Solution Verified - Updated -

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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content