What is linux "-f" or linux "-z" or linux "-eq" or linux "-gt" or linux "-rf" or linux "-le" ?The short answer for the above is that those are number and file tests/comparisons of korn/bash shells. Linux shells are the primary ways the users interact with Linux operating systems. With shells you can interact with the file system and execute programs. You can chain shell commands in scripts in a programmatic way.
Number and file tests/comparisons occur in shell scripting constructs such as :
You can replace the "true" between the [] with expressions that evaluate to true or false, for example:if [ true ] then # do something here fi
The above decisional block in plain english is " if 5 equals 5 print the string "5 equals 5" ".if [ 5 -eq 5 ] then echo "5 equals 5" fi
File tests/comparisons are:
"-d" file Test if file is a directory
"-e" file Test if file exists
"-f" file Test if file is an ordinary file
"-r" file Test if file is readable
"-w" file Test if file is writable
"-x" file Test if file is executable
Numeric comparison operators are:
"-eq" Checks if two operands are equal or not
"-ne" Checks if two operands are equal or not, if values are not equal then condition becomes true.
"-gt" Checks if left operand is greater than right operand
"-lt" Checks if left operand is less than right operand
"-ge" Checks if left operand is greater than or equal to right operand
"-le" Checks if left operand is less than or equal to right operand
I usually give people that want to learn shell scripting the finger/
This was another linux stuff article that nobody proably gives a damn about it.
No comments :
Post a Comment