0% found this document useful (0 votes)
37 views

Find /gpfs/scratch/username - Atime +21: For String Comparisons Use Operator Meaning

This document provides information on string and file comparisons that can be used with the test and [[ commands in shell scripts. It lists operators for comparing strings and their meanings, as well as tests for checking different file types and attributes along with their meanings.
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Find /gpfs/scratch/username - Atime +21: For String Comparisons Use Operator Meaning

This document provides information on string and file comparisons that can be used with the test and [[ commands in shell scripts. It lists operators for comparing strings and their meanings, as well as tests for checking different file types and attributes along with their meanings.
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

cpan --force ExtUtils::MakeMaker

find /gpfs/scratch/username -atime +21


For string Comparisons use

Operator Meaning
string1 = string2 string1 is equal to string2
string1 != string2 string1 is NOT equal to string2
string1 string1 is NOT NULL or not defined
-n string1 string1 is NOT NULL and does exist
-z string1 string1 is NULL and does exist
Shell also test for file and directory types

Test Meaning
True if file exists
-a file
True if file exists and is a block special
-b file file.

True if file exists and is a character


-c file
special file.
True if file exists and is a directory.
-d file
True if file exists.
-e file
True if file exists and is a regular file.
-f file

True if file exists and its set-group-id


-g file bit is set.

True if file exists and is a symbolic


-h file link.

True if file exists and its "sticky" bit is


-k file set.

True if file exists and is a named pipe


-p file (FIFO).

True if file exists and is readable.


-r file

-s file True if file exists and has a size


greater than zero.

True if file descriptor fd is open and


-t fd refers to a terminal.

True if file exists and its set-user-id bit


-u file is set.

True if file exists and is writable.


-w file

True if file exists and is executable.


-x file

True if file exists and is owned by the


-G file effective group id.

True if file exists and is a symbolic


-L file link.

True if file exists and has been


-N file modified since it was last read.

True if file exists and is owned by the


-O file effective user id.

True if file exists and is a socket.


-S file

True if the shell option optname is


-o optname
enabled.

True if the shell variable varname is


-v varname
set (has been assigned a value).

True if the shell variable varname is


-R varname
set and is a name reference.

-z string True if the length of string is zero.

True if file1 and file2 refer to the same


file1effile2 device and inode numbers.

file1ntfile2 True if file1 is newer (according to


modification date) than file2, or if
file1 exists and file2 does not.

True if file1 is older than file2, or if


file1otfile2 file2 exists and file1 does not.

string1==string2
string1=string2
True if the strings are equal. When used with the [[ command, this performs
pattern matching as described above (see Conditional Constructs).

= should be used with the test command for POSIX conformance.

string1!=string2
True if the strings are not equal.

string1<string2
True if string1 sorts before string2 lexicographically.

string1>string2
True if string1 sorts after string2 lexicographically.

arg1OParg2
OP is one of eq, ne, lt, le, gt, or ge. These arithmetic binary
operators return true if arg1 is equal to, not equal to, less than, less than or
equal to, greater than, or greater than or equal to arg2, respectively. Arg1
and arg2 may be positive or negative integers.

You might also like