How do I evaluate or calculate the return value of a command line? For exemple, I count the number of lines with a grep and I want to know if that value is above X. If so, I want to print the number to a file.
Or I want to substract the value of a grep count to another grep count...
How can I manipulate return values that way ?
$?
is the 8-bit exit status of each program. Values of0
and1
have standard definitions. Values2
through255
are reserved for the program - it may return more information, check theman
page for the particular program. Some usages ignore this extra information, and treat$?
value0
as Success, anything else as Not-Success (Failure). – waltinator Apr 02 '22 at 18:23