-nt : Newer than
-ot : Older than
-gt : Greater than
-lt : Less than
-ge : Greater than or equal to
-le : less than or equal to
-eq : equal to
-ne : not equal to
check if the name "abc" is file or not
test -f abc; echo $? - if o/p is 0 then its a file else its a directory
also,
[-f abc]; echo $?
to check socket files eg mysql.sock
test -S /var/lib/mysql/mysql.sock; echo $? - if o/p is 0 then its socket file else not
To check null (zero size) files
test -s log1.log; echo $? - if o/p is 0 then its not a zero byte file.
man test - for all details
-ot : Older than
-gt : Greater than
-lt : Less than
-ge : Greater than or equal to
-le : less than or equal to
-eq : equal to
-ne : not equal to
check if the name "abc" is file or not
test -f abc; echo $? - if o/p is 0 then its a file else its a directory
also,
[-f abc]; echo $?
to check socket files eg mysql.sock
test -S /var/lib/mysql/mysql.sock; echo $? - if o/p is 0 then its socket file else not
To check null (zero size) files
test -s log1.log; echo $? - if o/p is 0 then its not a zero byte file.
man test - for all details