Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to check if a file is empty? Post 302234148 by dennis.jacob on Tuesday 9th of September 2008 08:21:00 AM
Old 09-09-2008
Try :

Code:
[[ -s "file" ]] && echo "Filesize not zero" || echo "Filesize zero"

Am not quite sure you are looking for the condition filesize is zero or records zero.
This User Gave Thanks to dennis.jacob For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to check for empty file in Perl?

Hi, May I know how to check for empty file in Perl. Iam missing something, somewhere. #!/usr/bin/perl my $open_dir = '/path/'; my $file; my $ma = "abc_.*.\.psv\$" opendir(VAR, $open_dir) or die "Can't open $oepn_dir: $!\n"; while( defined ($file = readdir VAR) ) #read all... (1 Reply)
Discussion started by: deepakwins
1 Replies

2. UNIX for Dummies Questions & Answers

to check if file is empty or not and return a non zero value

Hi All, I am new to unix worldd . I need to check a file1 if its empty or not. If its empty then return a non zero value say 99 could you pls let me know the perl script for this. (2 Replies)
Discussion started by: mavesum
2 Replies

3. Shell Programming and Scripting

check if file is empty

How do I check if a file is empty in a sh script I want to test in my shell script if the output file is empty and if it is do one thing and if it isnt empty do another? any ideas? (8 Replies)
Discussion started by: stolz
8 Replies

4. Shell Programming and Scripting

Need to check for empty file in C shell script

I am running a C shell script. I have an output file from a previous step and I need to run "something" in the next step to check if the file is empty. If the file is empty, then the job script should finish EOJ. If the file is not empty then the job script should abend. Please help Thanks. (4 Replies)
Discussion started by: jclanc8
4 Replies

5. Shell Programming and Scripting

Check if a text file is empty or not (using ls -s)

Hello, I want to make a script which says if a text file is empty or not. I tried two ways of making it, but I have problems with both of them. Now I think that the better way is the ls -s solution (considering that an empty text file has a 0 weight, because "cat file.txt" fails when file is... (4 Replies)
Discussion started by: Link_
4 Replies

6. Shell Programming and Scripting

Condition to check whether configuration file is empty or not?

CMD=$(find "${Release_Container}" -iname "${Release_Name}"_Release.txt) for i in `cat $CMD` do if ];then cd ${Sandbox_dir} CMD1=$(find "${Sandbox_dir}"/* -iname "${Release_Name}" -type d | awk -F/ '{print $(NF)}' | head -1 ) if ];then echo -e "################### CHECKOUT START... (2 Replies)
Discussion started by: anuragpgtgerman
2 Replies

7. UNIX for Dummies Questions & Answers

Check if file is empty with variables, bash

Hello again! I have some trouble with scripting in bash. In the following script I read from a folder with the files line0_Ux.xy line1_Ux.xy line2_Ux.xy . . . Some of the files are empty. For those I would like to print a "0" in list. I think the problem with the code is that... (4 Replies)
Discussion started by: bjoern456
4 Replies

8. Shell Programming and Scripting

Empty file check

Hi gurus , I have two files and i want to perform different action based on the condition if both or either is empty If then Do something elif then do something elif then do something else do something fi I have tried the below bt its not... (4 Replies)
Discussion started by: r_t_1601
4 Replies

9. Shell Programming and Scripting

How to check if the file is empty or has blank space.?

Hi, I am using KSH. I am trying to check if the output file is empty or not. I tried with ] but what i see is my file is empty but still manages to have a size of 1 instead of 0. But my file doesnot have anything its empty. I am not sure how to check this. can any one help? (10 Replies)
Discussion started by: Sharma331
10 Replies

10. Shell Programming and Scripting

To check whether the file is empty or not in shell script (sh)

Hi All, I need to check a file whether it exists and also whether it is empty or not. I have a code for this but it is not working as per my requirement. Can anyone pls suggest me on this. function funcFLSanityCheck { if then echo "${varFLSentFileListPath}/${varFLSentFileName}... (7 Replies)
Discussion started by: Arun1992
7 Replies
INI_GET(3)								 1								INI_GET(3)

ini_get - Gets the value of a configuration option

SYNOPSIS
string ini_get (string $varname) DESCRIPTION
Returns the value of the configuration option on success. PARAMETERS
o $varname - The configuration option name. RETURN VALUES
Returns the value of the configuration option as a string on success, or an empty string for null values. Returns FALSE if the configura- tion option doesn't exist. EXAMPLES
Example #1 A few ini_get(3) examples <?php /* Our php.ini contains the following settings: display_errors = On register_globals = Off post_max_size = 8M */ echo 'display_errors = ' . ini_get('display_errors') . " "; echo 'register_globals = ' . ini_get('register_globals') . " "; echo 'post_max_size = ' . ini_get('post_max_size') . " "; echo 'post_max_size+1 = ' . (ini_get('post_max_size')+1) . " "; echo 'post_max_size in bytes = ' . return_bytes(ini_get('post_max_size')); function return_bytes($val) { $val = trim($val); $last = strtolower($val[strlen($val)-1]); switch($last) { // The 'G' modifier is available since PHP 5.1.0 case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; } return $val; } ?> The above example will output something similar to: display_errors = 1 register_globals = 0 post_max_size = 8M post_max_size+1 = 9 post_max_size in bytes = 8388608 NOTES
Note When querying boolean values A boolean ini value of off will be returned as an empty string or "0" while a boolean ini value of on will be returned as "1". The function can also return the literal string of INI value. Note When querying memory size values Many ini memory size values, such as upload_max_filesize, are stored in the php.ini file in shorthand notation. ini_get(3) will return the exact string stored in the php.ini file and NOT its integer equivalent. Attempting normal arithmetic functions on these values will not have otherwise expected results. The example above shows one way to convert shorthand notation into bytes, much like how the PHP source does it. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | Previously, the empty string was returned if the | | | configuration option didn't exist. now, FALSE is | | | returned instead. | | | | +--------+---------------------------------------------------+ SEE ALSO
get_cfg_var(3), ini_get_all(3), ini_restore(3), ini_set(3). PHP Documentation Group INI_GET(3)
All times are GMT -4. The time now is 11:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy