Okay I will let users input spaces as well :)
I am having a mental block. I have done a couple of searches but havent found anything that I understand (the likes of :alpha: and awk).
Basically I want to give the user an option to enter some text which will go down as a field within a flat... (3 Replies)
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)
How do I test multiple words in a string test like below:
if ]
then
print "You entered $TBS name.\n"
else
print "You entered an incorrect response.\n"
fi
This test does not work. I have tried different syntax versions. How does this work? And is there a better way to do it?
... (10 Replies)
Hi there, I have a bunch of interface names like
e1000g0
nge1
dmfe3
I also have some that have longer (vlan tagged) names
like
e1000g123001
nge23003
e1000g999002
I need to determine whether the interface is one of the former or latter types and I would do that by seeing... (7 Replies)
Hi guys
I am performing a simple test for a blank string with the following code:
if ] ]] ; then
echo "Blanks are NOT a valid input "
return 1
fi
The above fails giving a syntax error message:
syntax error at line 142 : `=~' unexpected
I am in ksh88
is there... (2 Replies)
I want to find whether string values are available in a field of a file. Let it be any character other than number . I just want to know whether characters will be available in it . Please share a single step command for this without creating a shell script. (5 Replies)
Discussion started by: Sang
5 Replies
LEARN ABOUT PLAN9
test
TEST(1) General Commands Manual TEST(1)NAME
test - set status according to condition
SYNOPSIS
test expr
DESCRIPTION
Test evaluates the expression expr. If the value is true the exit status is null; otherwise the exit status is non-null. If there are no
arguments the exit status is non-null.
The following primitives are used to construct expr.
-r file True if the file exists (is accessible) and is readable.
-w file True if the file exists and is writable.
-x file True if the file exists and has execute permission.
-e file True if the file exists.
-f file True if the file exists and is a plain file.
-d file True if the file exists and is a directory.
-s file True if the file exists and has a size greater than zero.
-t fildes True if the open file whose file descriptor number is fildes (1 by default) is the same file as /dev/cons.
s1 = s2 True if the strings s1 and s2 are identical.
s1 != s2 True if the strings s1 and s2 are not identical.
s1 True if s1 is not the null string. (Deprecated.)
-n s1 True if the length of string s1 is non-zero.
-z s1 True if the length of string s1 is zero.
n1 -eq n2 True if the integers n1 and n2 are arithmetically equal. Any of the comparisons -ne, -gt, -ge, -lt, or -le may be used in place
of -eq. The (nonstandard) construct -l string, meaning the length of string, may be used in place of an integer.
These primaries may be combined with the following operators:
! unary negation operator
-o binary or operator
-a binary and operator; higher precedence than -o
( expr ) parentheses for grouping.
The primitives -b, -u, -g, and -s return false; they are recognized for compatibility with POSIX.
Notice that all the operators and flags are separate arguments to test. Notice also that parentheses and equal signs are meaningful to rc
and must be enclosed in quotes.
EXAMPLES
Test is a dubious way to check for specific character strings: it uses a process to do what an rc(1) match or switch statement can do. The
first example is not only inefficient but wrong, because test understands the purported string "-c" as an option.
if (test $1 '=' "-c") echo OK # wrong!
A better way is
if (~ $1 -c) echo OK
Test whether is in the current directory.
test -f abc -o -d abc
SOURCE
/sys/src/cmd/test.c
SEE ALSO rc(1)TEST(1)