How can I compare two integer values which is stored in char pointers?
suppose I have char *a and char *b having values 10 and 20. how can i find the shorter value? (1 Reply)
This is the code:
while test 1 -eq 1
do
read a
$a
if test $a = stop
then
break
fi
done
I read a command on every loop an execute it.
I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test.
For example echo hello.
Now the... (1 Reply)
Hi guys, I asked for help on programming forums and no one didn't helped me so I ask for help here. I am playing with some tasks from my book and I can't figure where did I get wrong.
From the first program I get a blank screen, program won't generate 10*10 matrix.
And second problem is I... (6 Replies)
Hi folks,
I am self-learning as I can
I have a script that has read a file into an array.
I can read out each line in the array with the code:
for INDEX in {0..$LENGTH} ## $LENGTH was determined at the read in
do
echo "${data}"
done
What I need to do is test the first char... (2 Replies)
Working out a small problem, I have a need of a Perl snippet which might look something like this:
use integer;
...
if ($changingNumber / 2)
{
do something;
}
else
{
do something else;
}
...
What I want to happen is for "if" to resolve as "true" every time a whole... (3 Replies)
Discussion started by: LinQ
3 Replies
LEARN ABOUT ULTRIX
test
test(1) General Commands Manual test(1)Name
test - test conditional expression
Syntax
test expr
[ expr ]
Description
The command evaluates the expression expr. If the value of expr is true, the command returns a zero exit status; otherwise, it returns a
nonzero exit status. The command also returns a nonzero exit status if no arguments are specified.
Options
The following primitives are used to construct expr:
-r file Tests if the file exists and is readable.
-w file Tests if the file exists and is writable.
-f file Tests if the file exists and is not a directory.
-d file Tests if the file exists and is a directory.
-s file Tests if the file exists and has a size greater than zero.
-t [ fildes ] Tests if the open file, whose file descriptor number is fildes (1 by default), is associated with a terminal device.
-z s1 Tests if the length of string s1 is zero.
-n s1 Tests if the length of the string s1 is nonzero.
s1 = s2 Tests if the strings s1 and s2 are equal.
s1 != s2 Tests if the strings s1 and s2 are not equal.
s1 Tests if s1 is not the null string.
n1 -eq n2 Tests if number1 equals number2.
n1 -ge n2 Tests if number1 is greater than or equal to number2.
n1 -gt n2 Tests if number1 is greater than number2.
n1 -le n2 Tests if number1 is less than or equal to number2.
n1 -lt n2 Tests if number1 is less than number2.
n1 -ne n2 Tests if number1 is not equal to number2.
These primitives can be combined with the following operators:
!expr Negates evaluation of expression.
expr -a expr Tests logical and of two expressions.
expr -o expr Tests logical or of two expressions.
( expr... ) Groups expressions.
The -a operator takes precedence over the -o operator. Note that all the operators and flags are separate arguments to Note also that
parentheses are meaningful to the Shell and must be escaped.
See Alsofind(1), sh(1), test(1sh5)test(1)