Sponsored Content
Full Discussion: Filesize not working
Top Forums Shell Programming and Scripting Filesize not working Post 302225086 by vidyadhar85 on Thursday 14th of August 2008 01:56:04 PM
Old 08-14-2008
try this
rm -i `ls -lrt|awk '$5==0{print $9}'`
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

filesize

I know in php if you use the function filesize it will return the size of the file in bytes, but is there an easy way to get the size in MB. Cheers (2 Replies)
Discussion started by: jmg5
2 Replies

2. Shell Programming and Scripting

FileSize ???

How do I identify if there is any content in a file? If there is nothing in a specified file, I'd like to send an email indicating that there is nothing to report. Any help appreciated. (3 Replies)
Discussion started by: Cameron
3 Replies

3. UNIX for Dummies Questions & Answers

Sorting ls by filesize

I saw some stuff in the search results on this - but nothing specific..... I have a significant number of files (c. 300) which are output from a large process that I run. These are compared with a 'baselined' set of files - so I can quickly see if there are differences based on the sizes of the... (2 Replies)
Discussion started by: peter.herlihy
2 Replies

4. Shell Programming and Scripting

How to truncate as filesize?

Hello everybody it's me again. I have a procces that is writing in a 'file1' automatically but i want to truncate 'file1' to a filesize 'x' that mean if the 'file1' size is 'x' i want to delete the first lines while the last lines are being writed, that have sence? in the process are an... (1 Reply)
Discussion started by: Lestat
1 Replies

5. UNIX for Dummies Questions & Answers

UNIX and filesize

Hey guys. What I need to do is this: I need to find files that have a certain filesize (for this case a file size of 0 (zero) ) When I find this file with a filesize of zero I need to echo a statement that tells the user to delete it and not to delete it if the filesize is greater than... (3 Replies)
Discussion started by: ndoggy020
3 Replies

6. Shell Programming and Scripting

filesize

I want to know if there is any unix command to view the size of the file? eg. i have a directory letter in this i have file a,b,c,d,e. i just want to know the size of file d and not any other. (3 Replies)
Discussion started by: infyanurag
3 Replies

7. Shell Programming and Scripting

getting filesize

Hello, I have a script that should store file size in a variable $filesize. I don't know what is the best way to do it. I tried ls -lt myfile.txt | sed something >$filesize but I don't know how to use sed to get filesize. I know that the owner of the file is root and then we have some... (6 Replies)
Discussion started by: pppswing
6 Replies

8. Solaris

Check for filesize limit

How do I check for any file size limitations in a directories ? I remember my administrator had set a file limitation for a certain directory. I would like to know how I can check that. Thank you. (2 Replies)
Discussion started by: Leion
2 Replies

9. AIX

listing the whole system by filesize

Hi, Just wondered what command you would use to list all the files on Aix by filesize? I've tried a few but none of which seem to do the trick! Currently running du -m -a . | sort -rn | more as root Thanks, Matt. (1 Reply)
Discussion started by: elmesy
1 Replies

10. Shell Programming and Scripting

if condition for filesize

Hi, I want to check file size in unix, based on file size I am going to execute appropriate command. I tried below, but getting the error. System details – Machine hardware: sun4u OS version: 5.9 if ( -s $f1 ) then echo "filename exists and is > 0 bytes" else echo "filename... (7 Replies)
Discussion started by: rahulbahulekar
7 Replies
STREAM_NOTIFICATION_CALLBACK(3) 					 1					   STREAM_NOTIFICATION_CALLBACK(3)

stream_notification_callback - A callback function for the notificationcontext parameter

SYNOPSIS
void stream_notification_callback (int $notification_code, int $severity, string $message, int $message_code, int $bytes_transferred, int $bytes_max) DESCRIPTION
A callable function, used by the notification context parameter, called during an event. Note This is not a real function, only a prototype of how the function should be. PARAMETERS
o $notification_code - One of the STREAM_NOTIFY_* notification constants. o $severity - One of the STREAM_NOTIFY_SEVERITY_* notification constants. o $message - Passed if a descriptive message is available for the event. o $message_code - Passed if a descriptive message code is available for the event. The meaning of this value is dependent on the specific wrapper in use. o $bytes_transferred - If applicable, the $bytes_transferred will be populated. o $bytes_max - If applicable, the $bytes_max will be populated. RETURN VALUES
No value is returned. EXAMPLES
Example #1 stream_notification_callback(3) example <?php function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) { switch($notification_code) { case STREAM_NOTIFY_RESOLVE: case STREAM_NOTIFY_AUTH_REQUIRED: case STREAM_NOTIFY_COMPLETED: case STREAM_NOTIFY_FAILURE: case STREAM_NOTIFY_AUTH_RESULT: var_dump($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max); /* Ignore */ break; case STREAM_NOTIFY_REDIRECTED: echo "Being redirected to: ", $message; break; case STREAM_NOTIFY_CONNECT: echo "Connected..."; break; case STREAM_NOTIFY_FILE_SIZE_IS: echo "Got the filesize: ", $bytes_max; break; case STREAM_NOTIFY_MIME_TYPE_IS: echo "Found the mime-type: ", $message; break; case STREAM_NOTIFY_PROGRESS: echo "Made some progress, downloaded ", $bytes_transferred, " so far"; break; } echo " "; } $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); file_get_contents("http://php.net/contact", false, $ctx); ?> The above example will output something similar to: Connected... Found the mime-type: text/html; charset=utf-8 Being redirected to: http://no.php.net/contact Connected... Got the filesize: 0 Found the mime-type: text/html; charset=utf-8 Being redirected to: http://no.php.net/contact.php Connected... Got the filesize: 4589 Found the mime-type: text/html;charset=utf-8 Made some progress, downloaded 0 so far Made some progress, downloaded 0 so far Made some progress, downloaded 0 so far Made some progress, downloaded 1440 so far Made some progress, downloaded 2880 so far Made some progress, downloaded 4320 so far Made some progress, downloaded 5760 so far Made some progress, downloaded 6381 so far Made some progress, downloaded 7002 so far Example #2 Simple progressbar for commandline download client <?php function usage($argv) { echo "Usage: "; printf(" php %s <http://example.com/file> <localfile> ", $argv[0]); exit(1); } function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) { static $filesize = null; switch($notification_code) { case STREAM_NOTIFY_RESOLVE: case STREAM_NOTIFY_AUTH_REQUIRED: case STREAM_NOTIFY_COMPLETED: case STREAM_NOTIFY_FAILURE: case STREAM_NOTIFY_AUTH_RESULT: /* Ignore */ break; case STREAM_NOTIFY_REDIRECTED: echo "Being redirected to: ", $message, " "; break; case STREAM_NOTIFY_CONNECT: echo "Connected... "; break; case STREAM_NOTIFY_FILE_SIZE_IS: $filesize = $bytes_max; echo "Filesize: ", $filesize, " "; break; case STREAM_NOTIFY_MIME_TYPE_IS: echo "Mime-type: ", $message, " "; break; case STREAM_NOTIFY_PROGRESS: if ($bytes_transferred > 0) { if (!isset($filesize)) { printf(" Unknown filesize.. %2d kb done..", $bytes_transferred/1024); } else { $length = (int)(($bytes_transferred/$filesize)*100); printf(" [%-100s] %d%% (%2d/%2d kb)", str_repeat("=", $length). ">", $length, ($bytes_transferred/1024), $filesize/1024); } } break; } } isset($argv[1], $argv[2]) or usage($argv); $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); $fp = fopen($argv[1], "r", false, $ctx); if (is_resource($fp) && file_put_contents($argv[2], $fp)) { echo " Done! "; exit(0); } $err = error_get_last(); echo " Errrrrorr.. ", $err["message"], " "; exit(1); ?> Executing the example above with: php -n fetch.php http://no2.php.net/get/php-5-LATEST.tar.bz2/from/this/mirror php-latest.tar.bz2 will output something similar too: Connected... Mime-type: text/html; charset=utf-8 Being redirected to: http://no2.php.net/distributions/php-5.2.5.tar.bz2 Connected... Filesize: 7773024 Mime-type: application/octet-stream [========================================> ] 40% (3076/7590 kb) SEE ALSO
"Context parameters". PHP Documentation Group STREAM_NOTIFICATION_CALLBACK(3)
All times are GMT -4. The time now is 12:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy