Snalk

Snalk » OS Tutorials » Linux » The Operators for Test Expressions for Writing Shell Scripts in Fedora

Reply
  #1 (permalink)  
Old 08-20-2008, 05:18 AM
Senior Member
 
Join Date: Aug 2008
Posts: 128
Post The Operators for Test Expressions for Writing Shell Scripts in Fedora

The Operators for Test Expressions for Writing Shell Scripts in Fedora


-a file: Check that the file exists (same as –e).

-b file: Check whether the file is a special block device.

-c file: Check whether the file is a character special device.

-d file: Check whether the file is a directory.

-e file: Check whether the file exists (same as -a).

-f file: Check whether the file exists and is a regular file (for example, not a directory, socket, pipe, link, or device file).

-g file: Check whether the file has the set-group-id bit set.

-h file: Check whether the file is a symbolic link (same as –L).

-k file: Check whether the file has the sticky bit set.

-L file: Check whether the file is a symbolic link (same as -h).

-n string: Check whether the string length is greater than 0 bytes.

-O file: Check whether you own the file.

-p file: Check whether the file is a named pipe.

-r file: Check whether the file is readable by you.

-s file: Check whether the file exists and is larger than 0 bytes.

-S file: Check whether the file exists and is a socket.

-t fd: Check whether the file descriptor is connected to a terminal.

-u file: Check whether the file has the set-user-id bit set.

-w file: Check whether the file is writable by you.

-x file: Check whether the file is executable by you.

-z string: Check whether the length of the string is 0 (zero) bytes.

expr1 -a expr2: Check whether both the first and the second expressions are true.

expr1 -o expr2: Check whether either of the two expressions is true.

file1 -nt file2: Check whether the first file is newer than the second file (using the modification timestamp).

file1 -ot file2: Check whether the first file is older than the second file (using the modification timestamp).

file1 -ef file2: Check whether the two files are associated by a link (a hard link or a symbolic link).

var1 = var2: Check whether the first variable is equal to the second variable.

var1 -eq var2: Check whether the first variable is equal to the second variable.

var1 -ge var2: Check whether the first variable is greater than or equal to the second variable.

var1 -gt var2: Check whether the first variable is greater than the second variable.

var1 -le var2: Check whether the first variable is less than or equal to the second variable.

var1 -lt var2: Check whether the first variable is less than the second variable.

var1 != var2, var1 -ne var2: Check whether the first variable is not equal to the second variable.
Reply With Quote
Reply

Bookmarks

Tags
fedora, operators, shell scripts, test expressions

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump



All times are GMT. The time now is 12:46 PM.
Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.