TEST(1) General Commands Manual TEST(1)NAME
test, [ - test for a condition
SYNOPSIS
test expr
[ expr ]
OPTIONS
(none)
EXAMPLES
test -r file # See if file is readable
DESCRIPTION
Test checks to see if files exist, are readable, etc. and returns an exit status of zero if true and nonzero if false. The legal operators
are
-r file true if the file is readable
-w file true if the file is writable
-x file true if the file is executable
-f file true if the file is not a directory
-d file true if the file is a directory
-s file true if the file exists and has a size > 0
-t fd true if file descriptor fd (default 1) is a terminal
-z s true if the string s has zero length
-n s true if the string s has nonzero length
s1 = s2 true if the strings s1 and s2 are identical
s1 != s2 true if the strings s1 and s2 are different
m -eq m true if the integers m and n are numerically equal
The operators -gt, -ge, -ne, -le, and -lt may be used as well. These operands may be combined with -a (Boolean and), -o (Boolean or), !
(negation). The priority of -a is higher than that of -o. Parentheses are permitted, but must be escaped to keep the shell from trying to
interpret them.
SEE ALSO expr(1), sh(1).
TEST(1)
Check Out this Related Man Page
TEST(1) General Commands Manual TEST(1)NAME
test - condition command
SYNOPSIS
test expr
DESCRIPTION
test evaluates the expression expr, and if its value is true then returns zero exit status; otherwise, a non zero exit status is returned.
test returns a non zero exit if there are no arguments.
The following primitives are used to construct expr.
-r file true if the file exists and is readable.
-w file true if the file exists and is writable.
-f file true if the file exists and is not a directory.
-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 associated with a terminal device.
-z s1 true if the length of string s1 is zero.
-n s1 true if the length of the string s1 is nonzero.
s1 = s2 true if the strings s1 and s2 are equal.
s1 != s2 true if the strings s1 and s2 are not equal.
s1 true if s1 is not the null string.
n1 -eq n2
true if the integers n1 and n2 are algebraically equal. Any of the comparisons -ne, -gt, -ge, -lt, or -le may be used in place of
-eq.
These primaries may be combined with the following operators:
! unary negation operator
-a binary and operator
-o binary or operator
( expr )
parentheses for grouping.
-a has higher precedence than -o. Notice that all the operators and flags are separate arguments to test. Notice also that parentheses
are meaningful to the Shell and must be escaped.
SEE ALSO sh(1), find(1)TEST(1)
A goofy UNIX test:
http://www.majon.com/cgi-bin/IQ?Q=unix
WARNING: ANSWERS ARE BELOW!!!!
IF YOU WANT TO DO THE TEST BEFORE SEEING THE ANSWERS, DON"T READ FURTHER ;) (13 Replies)
I'm new to scripting and I need help with a bourn shell script. What i'm trying to do is a test condition where "if the time is within 2 hours, it's true" and so on.
The time is in the following format
DATE=`/bin/date +"%Y%m%d%H%S"`
for example, 20060907152000.
So, what the script first... (9 Replies)
i am using solaris 5.10. i can create two different files "test" and ".test" in the same directory. now suppose i want to change the attribute of the hidden file .test to visible is it possible???
since "." is just an attribute to mark a file hidden why is unix allows creation of "file" and... (14 Replies)
I am doing the following script in k shell
sed -i 's/FILENAME/$i/g' TEST/test$j.ctl > TEST/control$j.ctl
In the file it replaces $i for all FILENAME, it doesnot replace with the value of i. I put single quotes like below
sed -i 's/FILENAME/'$i'/g' TEST/test$j.ctl > TEST/control$j.ctl
I... (9 Replies)
I would like to add 4.7 and 1.2. However I am unable to do this with expr.
Any simple ideas (even using something other than expr)?
Example:
me> expr 4 + 1
5
me> expr 4.7 + 1.2
expr: 0402-046 A specified operator requires numeric parameters. (18 Replies)
Hi All,
I need to search in a csv file as mentioend in the Appendix A for a exact word lets "TEST".
But using teh below command iam getting TEST1234, TEST12 and otehr entries as well.
the problem is i check this condition to check to add a record to a table by making sure it does not... (16 Replies)
Hi,
Suppose in some directory (/APPS/TEST) I have a file ABCTEST.csv. I want to write a IF condition in which I want to check if filename contains the string ABC then I will do certain operations .
I have a variable having value as /APPS/TEST/ABCTEST.csv
How Can I achieve this...please... (14 Replies)
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)
Hello Friends,
I have written a code on a Linux box, however, am getting issues while running it on a Solaris server. The issue with Sed command is sortd out, however, am still lokking for solutions with expr command. Here is the issue,
Linux :
bash-2.03$ expr match singh@test.com... (10 Replies)
Hello,
I need help with a test command.
Here is what I am trying to do :
I've got an interactive script that check if configuration files exist on 2 different directories, then all configuration files are print on screen by a short name.
My problem is when you type a "wrong name" or... (12 Replies)
How do i make a hardlink readable,writable, and executable by me?
I am kinda hoping for a command i can use
Also, i was wondering what file type are hardlinks and softlinks?Are they directories? (10 Replies)
Hi I have data in the below format in two columns in excel which i will copy to notepad.
test as rec1, string
test as rec2, byteint
test as rec3, string
update date as test, datetime
name as tes2 string
I need to add trim function on all the string columns and keep the remaining... (10 Replies)