Check the size of files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Check the size of files
# 1  
Check the size of files

Hi,

I need to put a script working to see in a directory with logs if exists file or files with size more than 12Mb.
If exists it shoul send mail.

Can anyone help me?

thanks
# 2  
Code:
FILES=`find . -type f -size +23999 -print`
if [[ -n "${FILES}" ]]; then
     echo "Hey, I found some files larger than 12 MB!" |\
     mail -s 'Files > 12 MB found!' you@domain.org
else
     echo "Nothing of interest found."
fi

exit 0

# 3  
Hi, thanks for you help.

Tell me another thing, the 23999 value i supose is the same as 12Mb?
How this values appears?

Sorry for my newbie questions?

Quote:
Originally Posted by zaxxon
Code:
FILES=`find . -type f -size +23999 -print`
if [[ -n "${FILES}" ]]; then
     echo "Hey, I found some files larger than 12 MB!" |\
     mail -s 'Files > 12 MB found!' you@domain.org
else
     echo "Nothing of interest found."
fi

exit 0

# 4  
CPU & Memory Please find the man page for find command

-size n[c] True if the file is n blocks long (512 bytes
per block). If n is followed by a c, the
size is in bytes.


If you want to print the files with size more than 12MB(12582912 bytes) , use the below command:

find . -type f -size +12582912c -print

"+" sign for files more than 12mb and "-" sign for files less than 12 MB.
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #128
Difficulty: Easy
Generally speaking, most of the software included in a Linux distro is free and open source.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check total files size in hdfs directory?

Is there a way to calculate the total file size of HDFS file directory in GB or MB? I dont want to use du/df command. Without that is there a way HDFS Directory - /test/my_dir (1 Reply)
Discussion started by: rohit_shinez
1 Replies

2. Shell Programming and Scripting

check the file size

if ; then cp /tmp/testfolder/*.* ~/new/logs/ else echo "No files today" exit fi The problem is this doen't work when there is more than 1 file. Please tell me how to take the latest file and check the size of the file in a directory (1 Reply)
Discussion started by: sandy1028
1 Replies

3. SCO

check partitions size in MB

hi Howto check partitions size in MB on SCO 5.0.6? Using df command I can see just in blocks. (4 Replies)
Discussion started by: ccc
4 Replies

4. Shell Programming and Scripting

Check the file size - help

I want to write a batch job (ksh) with the following requirement we have file feeds coming to our system from other team, if the file size is greater than expected then we dont need to process the file for the day and need to archive the file and send email notification to the manager saying... (5 Replies)
Discussion started by: sithara
5 Replies

5. Shell Programming and Scripting

Check file size and remove files

Hi, Here we have a situation where we have to check the file size and if the file size is greater than 0 bytes then remove the files from the directory. 1)EdwTrxn 2)EdwPost 3)EdwTndr 4)EdwSls 5)EdwSlsRej 6)EdwTndrRej Files will be created in the directory in the following manner. ... (5 Replies)
Discussion started by: srivsn
5 Replies

6. Shell Programming and Scripting

To check file size

Hi All, I am in small problem.. i have one script which transfers some big files to my ftp usign normal command like put .... my problem is how to check whether my file have been transferred successfully on ftp or not... i know only inside ftp we have option like 'size' command which... (2 Replies)
Discussion started by: Shahul
2 Replies

7. Shell Programming and Scripting

bash script working for small size files but not for big size files.

Hi, I have one file stat. Stat file contents are as follows: for example. H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000 H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000 Now i... (1 Reply)
Discussion started by: davidpreml
1 Replies

8. UNIX for Dummies Questions & Answers

How to check directory size

how say I have directory how can I get the directory size in mega and if it less then 1 mega so byts Thanks (4 Replies)
Discussion started by: umen
4 Replies

9. UNIX for Dummies Questions & Answers

Check file size

I need a unix script that will check the size of multiple files in the same directory or from a text file. (6 Replies)
Discussion started by: alnita
6 Replies

10. Shell Programming and Scripting

How to check if 3 files have same size in directory

I need to determine if any three files have the same file size in a specified directly? I have got as far as listing the file sizes but where to go from here? ls -al |sort -n -r +4 | awq '{print $5}' Thanks in anticipation (5 Replies)
Discussion started by: oggle
5 Replies

Featured Tech Videos