
- Unix / Linux - Home
- Unix / Linux - What is Linux?
- Unix / Linux - Getting Started
- Unix / Linux - File Management
- Unix / Linux - Directories
- Unix / Linux - File Permission
- Unix / Linux - Environment
- Unix / Linux - Basic Utilities
- Unix / Linux - Pipes & Filters
- Unix / Linux - Processes
- Unix / Linux - Communication
- Unix / Linux - The vi Editor
- Unix / Linux - Shell Scripting
- Unix / Linux - What is Shell?
- Unix / Linux - Using Variables
- Unix / Linux - Special Variables
- Unix / Linux - Using Arrays
- Unix / Linux - Basic Operators
- Unix / Linux - Decision Making
- Unix / Linux - Shell Loops
- Unix / Linux - Loop Control
- Unix / Linux - Shell Substitutions
- Unix / Linux - Quoting Mechanisms
- Unix / Linux - IO Redirections
- Unix / Linux - Shell Functions
- Unix / Linux - Manpage Help
- Advanced Unix / Linux
- Unix / Linux - Standard I/O Streams
- Unix / Linux - File Links
- Unix / Linux - Regular Expressions
- Unix / Linux - File System Basics
- Unix / Linux - User Administration
- Unix / Linux - System Performance
- Unix / Linux - System Logging
- Unix / Linux - Signals and Traps
Unix / Linux - C Shell Operators
We will now list down all the operators available in C Shell. Here most of the operators are very similar to what we have in C Programming language.
Operators are listed in the order of decreasing precedence −
Arithmetic and Logical Operators
The following table lists out a few Arithmetic and Logical Operators −
Sr.No. | Operator & Description |
---|---|
1 |
( ) Change precedence |
2 |
~ 1's complement |
3 |
! Logical negation |
4 |
* Multiply |
5 |
/ Divide |
6 |
% Modulo |
7 |
+ Add |
8 |
- Subtract |
9 |
<< Left shift |
10 |
>> Right shift |
11 |
== String comparison for equality |
12 |
!= String comparison for non equality |
13 |
=~ Pattern matching |
14 |
& Bitwise "and" |
15 |
^ Bitwise "exclusive or" |
16 |
| Bitwise "inclusive or" |
17 |
&& Logical "and" |
18 |
|| Logical "or" |
19 |
++ Increment |
20 |
-- Decrement |
21 |
= Assignment |
22 |
*= Multiply left side by right side and update left side |
23 |
/= Divide left side by right side and update left side |
24 |
+= Add left side to right side and update left side |
25 |
-= Subtract left side from right side and update left side |
26 |
^= "Exclusive or" left side to right side and update left side |
27 |
%= Divide left by right side and update left side with remainder |
File Test Operators
The following operators test various properties associated with a Unix file.
Sr.No. | Operator & Description |
---|---|
1 |
-r file Checks if file is readable; if yes, then the condition becomes true. |
2 |
-w file Checks if file is writable; if yes, then the condition becomes true. |
3 |
-x file Checks if file is executable; if yes, then the condition becomes true. |
4 |
-f file Checks if file is an ordinary file as opposed to a directory or special file; if yes, then the condition becomes true. |
5 |
-z file Checks if file has size greater than 0; if yes, then the condition becomes true. |
6 |
-d file Checks if file is a directory; if yes, then the condition becomes true. |
7 |
-e file Checks if file exists; is true even if file is a directory but exists. |
8 |
-o file Checks if user owns the file; returns true if the user is the owner of the file. |