270 272




Linux Unleashed, Third Edition:Shell Programming





-->















Previous
Table of Contents
Next




The tcsh Equivalent of the test Command
The tcsh does not have a test command, but it supports the same function using expressions. The expression operators that tcsh supports are almost identical to those supported by the C language. These expressions are used mostly in the if and while commands, which are covered later in this chapter in the “Conditional Statements” and “Iteration Statements” sections.
The tcsh expressions support the same kind of operators as the bash and pdksh test command. These are integer, string, file, and logical expressions. The integer operators supported by tcsh expressions are listed in Table 14.6.
Table 14.6. The tcsh expression integer operators.



Operator
Meaning



int1 <= int2
Returns True if int1 is less than or equal to int2.

int1 >= int2
Returns True if int1 is greater than or equal to int2.

int1 < int2
Returns True if int1 is less than int2.

int1 > int2
Returns True if int1 is greater than int2.



The string operators that tcsh expressions support are listed in Table 14.7.
Table 14.7. The tcsh expression string operators.



Operator
Meaning



str1 == str2
Returns True if str1 is equal to str2.

str1 != str2
Returns True if str1 is not equal to str2.



The file operators that tcsh expressions support are listed in Table 14.8.
Table 14.8. The tcsh expression file operators.



Operator
Meaning



-r file
Returns True if file is readable.

-w file
Returns True if file is writable.

-x file
Returns True if file is executable.

-e file
Returns True if file exists.

-o file
Returns True if file is owned by the current user.

-z file
Returns True if file is of size 0.

-f file
Returns True if file is a regular file.

-d file
Returns True if file is a directory file.



The logical operators that tcsh expressions support are listed in Table 14.9.
Table 14.9. The tcsh expression logical operators.



Operator
Meaning



exp1 || exp2
Returns True if exp1 is true or if exp2 is true.

exp1 && exp2
Returns True if exp1 is true and exp2 is true.

! exp
Returns True if exp is not true.



Conditional Statements
The bash, pdksh, and tcsh each have two forms of conditional statements. These are the if statement and the case statement. These statements are used to execute different parts of your shell program depending on whether certain conditions are true. As with most statements, the syntax for these statements is slightly different between the different shells.



Previous
Table of Contents
Next














Wyszukiwarka

Podobne podstrony:
272?1105 operator koparko ladowarki
272 275
SHSpec 272 6306C11 Engram Chain Running
272 273
268 270
demo cgi 272
Śpiewnik 270
3500classic RM 272 RM 273 schematics v1 0
272 273
Warunki techniczne zmiana 2002 12 16 Dz U 2003 33 270
demo cgi 270
Nuestro Circulo 270 Octavio Troianescu

więcej podobnych podstron