1. Integers comparison : -eq,-le,-ge,-ne,-lt,gt
2. String comparison
test hello_world = hello_word; echo $? -> result is 0
test hello_worlds = hello_word; echo $? -> result is 1
test hello_worlds != hello_word; echo $? -> result is 0
3. touch testFile1 -> create files
touch testFile2
test testFile1 -nt testFile1; echo $? - test that testFile1 is newer that testFile2 the teslt is 1
test testFile1 -ot testFile1; echo $? - result 0
4. /dev/cua0;/dev/cua1 - caracter devices(serial devices)
test -b testFile; echo $? - test if file is a block file device; result is 1
test -c testFile; echo $? - test if file is a caracter device; result is 0
5. rm -rf testFile - removes folder testFile
6. mkdir testFolder - creates a folder
test -f testFolder;echo $? - tests if testFolder is a file; Result is 1
touch testFile
test -f testFile; echo $? -> tests if testFile is a file; Result is 0
7. In a script file you test a file in the following way [ -f testFile ]
8. ls -l /var/lib/mysql/mysql.sock
test -S /var/lib/mysql/mysql.sock ; echo $? -> result is 0 - test if a file is a socket with option "-S"
A socket file has the following form srwxrwxrwx after a 'ls -l' command
9. Using uption "-s" tests if a file is non zero
test -s testFile ; echo #? -> result is 1 if the file has zero bytes or 0 if the file size is greater than zero
10. man test - documentation for "test" command
No comments:
Post a Comment