Sponsored Content
Full Discussion: What -f can do?
Top Forums UNIX for Dummies Questions & Answers What -f can do? Post 302922916 by RavinderSingh13 on Wednesday 29th of October 2014 05:58:31 AM
Old 10-29-2014
Hello cmarzan,

-f filename is true if a file exits and it is a regular file or not. You can refer man test also for same.

Following is an example for same.
Code:
if [ -f  Filename ]
then
       echo "file exits."
else
       echo "file is NOT there."
fi


Thanks,
R. Singh

Last edited by RavinderSingh13; 10-29-2014 at 11:27 AM.. Reason: corrected typo of a space in b/w filename and ] thanks to Aia for same.
This User Gave Thanks to RavinderSingh13 For This Post:
 
BOOLVAL(3)								 1								BOOLVAL(3)

boolval - Get the boolean value of a variable

SYNOPSIS
boolean boolval (mixed $var) DESCRIPTION
Returns the boolean value of $var. PARAMETERS
o $var - The scalar value being converted to a boolean. RETURN VALUES
The boolean value of $var. EXAMPLES
Example #1 boolval(3) examples <?php echo '0: '.(boolval(0) ? 'true' : 'false')." "; echo '42: '.(boolval(42) ? 'true' : 'false')." "; echo '0.0: '.(boolval(0.0) ? 'true' : 'false')." "; echo '4.2: '.(boolval(4.2) ? 'true' : 'false')." "; echo '"": '.(boolval("") ? 'true' : 'false')." "; echo '"string": '.(boolval("string") ? 'true' : 'false')." "; echo '"0": '.(boolval("0") ? 'true' : 'false')." "; echo '"1": '.(boolval("1") ? 'true' : 'false')." "; echo '[1, 2]: '.(boolval([1, 2]) ? 'true' : 'false')." "; echo '[]: '.(boolval([]) ? 'true' : 'false')." "; echo 'stdClass: '.(boolval(new stdClass) ? 'true' : 'false')." "; ?> The above example will output: 0: false 42: true 0.0: false 4.2: true "": false "string": true "0": false "1": true [1, 2]: true []: false stdClass: true SEE ALSO
floatval(3), intval(3), strval(3), settype(3), is_bool(3), Type juggling. PHP Documentation Group BOOLVAL(3)
All times are GMT -4. The time now is 10:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy