Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Find command size greater than or equalto Post 303000761 by rbatte1 on Wednesday 19th of July 2017 08:24:24 AM
Old 07-19-2017
Would stat give you a getter output to work with? It gives you the output in a customisable format. Using ls or the -ls flag on find can cause issues if the file has a group name with spaces, for example:-
Code:
# stat bigfile
  File: `bigfile'
  Size: 6762219520	Blocks: 13207472   IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 2359475     Links: 1
Access: (0664/-rw-rw-r--)  Uid: (  500/rbatte1)   Gid: (  500/rbatte1)
Access: 2017-07-19 12:23:40.597780337 +0100
Modify: 2017-07-19 12:27:58.730711684 +0100
Change: 2017-07-19 12:28:17.474415803 +0100

It might not be neat, but if you use find to get a list of files based on whatever other criteria you have, you can then work through the list with some simple tests for file size, a bit like this:-
Code:
while read listed_file
do
   listed_file_size="$(stat -c%s${listed_file})
   if [ ${listed_file_size} -gt 10240 ]
   then
      echo "File ${listed_file} is greater than 10K at ${listed_file_size} bytes."
   fi
done < /tmp/file_list

Of course, you could substitute an input file for the output of your find command.

If you are looking for files over a certain size, then another option might be to call stat from your find with xargs, perhaps:-
Code:
find /path/to/search -type f any other options | xargs stat -c '%s %n' | sort -n

This will give you the files in size order, so once you have the first file that exceeds your limit, you can assume that all the others will too.


What is the full criteria of your search and what actions do you want to take? It would be useful to show us the output from uname -a too.

Thanks, in advance,
Robin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File size greater than 0

ok I want to know how to touch a file and find out that it is greater than 0 then if it is not I want to fail the job other wise I want to success amnd go on. Can anyone help. Thanks Shannon Kammer (1 Reply)
Discussion started by: skammer1234
1 Replies

2. Shell Programming and Scripting

Can I find wether a particular file exist and size greater than zero...help please

Can I find wether a particular file exist and size greater than zero in one line command. similar to this if && something in one if test .... e.g. if 1.) is it possible ? ... if yes how 2.) what would be the return type in case there is success or failure. I mean if both are... (4 Replies)
Discussion started by: guhas
4 Replies

3. UNIX for Dummies Questions & Answers

command(s) to find size of mysql database?

hello, i'm trying to figure out the size of a mysql database shelling into my server with putty / command line. is there / are there any commands that will return the size of a database, in MB? thanks. (4 Replies)
Discussion started by: sbourgeois
4 Replies

4. Solaris

command to find out total size of a specific file size (spread over the server)

hi all, in my server there are some specific application files which are spread through out the server... these are spread in folders..sub-folders..chid folders... please help me, how can i find the total size of these specific files in the server... (3 Replies)
Discussion started by: abhinov
3 Replies

5. Shell Programming and Scripting

Command/script to find size of Unix Box ?

Please could anyone provide me the Command/script to find the size and usage of Unix box ASAP ? (6 Replies)
Discussion started by: sakthifire
6 Replies

6. Shell Programming and Scripting

Filter the file list greater then the size specified by user

HI, Can any tell me how to filter the list of files greater than the size specified by user. The size should be provided by user as an input. Regards shiva (6 Replies)
Discussion started by: shivu
6 Replies

7. UNIX for Advanced & Expert Users

Find command -size option limitation ?

Hi All, I ran code in test environment to find the files more than 1TB given below is a snippet from code: FILE_SYSTEM=/home/arun MAX_FILE_LIMIT=1099511627776 find $FILE_SYSTEM -type f -size +"$MAX_FILE_LIMIT"c -ls -xdev 2>/dev/null | while read fname do echo "File larger than... (3 Replies)
Discussion started by: Arunprasad
3 Replies

8. Shell Programming and Scripting

shell script to check file size greater than 50M

Hi All, OS:AIX 64 bits using korn shell. Requirement: shell script to check file size greater than 50M and send mail alert. Thanks for your time! Regards, (3 Replies)
Discussion started by: a1_win
3 Replies

9. Shell Programming and Scripting

Unix file empty.. but size is greater than zero??/

Hi, I have a file by redirecting some contents in unix shell. Even when there is no content that is being redirected, the file size still shows greater than zero. but even if there is no matching pattern the file APPRES has size greater than 0bytes. awk -f AA.awk $logfile>APPRES... (3 Replies)
Discussion started by: justchill
3 Replies

10. HP-UX

find command to display size and date of a file

Hi, The blow code does not yeild any output. find . -name "*.jar" -o -name "*.ksh" -o -name "*.properties" -name "*.war" -o -name "*.ear" -o -name "*.sh" -o -name "*.cfg" -exec ls -l {} \; I wish to print the filename filesize filedate in HP-UX. Can anyone help ? (9 Replies)
Discussion started by: mohtashims
9 Replies
ff(1M)							  System Administration Commands						    ff(1M)

NAME
ff - list file names and statistics for a file system SYNOPSIS
ff [-F FSType] [-V] [generic_options] [-o specific_options] special... DESCRIPTION
ff prints the pathnames and inode numbers of files in the file system which resides on the special device special. Other information about the files may be printed using options described below. Selection criteria may be used to instruct ff to only print information for cer- tain files. If no selection criteria are specified, information for all files considered will be printed (the default); the -i option may be used to limit files to those whose inodes are specified. Output is sorted in ascending inode number order. The default line produced by ff is: path-name i-number The maximum information the command will provide is: path-name i-number size uid OPTIONS
-F Specify the FSType on which to operate. The FSType should either be specified here or be determinable from /etc/vfstab by matching the special with an entry in the table, or by consulting /etc/default/fs. -V Echo the complete command line, but do not execute the command. The command line is generated by using the options and arguments provided by the user and adding to them information derived from /etc/vfstab. This option may be used to verify and validate the command line. generic_options Options that are supported by most FSType-specific modules of the command. The following options are available: -I Do not print the i-node number after each path name. -l Generate a supplementary list of all path names for multiply-linked files. -p prefix The specified prefix will be added to each generated path name. The default is `.' (dot). -s Print the file size, in bytes, after each path name. -u Print the owner's login name after each path name. -a -n Select if the file has been accessed in n days. -m -n Select if the file has been written or created in n days. -c -n Select if file's status has been changed in n days. -n file Select if the file has been modified more recently than the argument file. -i i-node-list Generate names for only those i-nodes specified in i-node-list. i-node-list is a list of numbers separated by commas (with no intervening spaces). -o Specify FSType-specific options in a comma separated (without spaces) list of suboptions and keyword-attribute pairs for interpretation by the FSType-specific module of the command. OPERANDS
special A special device. USAGE
See largefile(5) for the description of the behavior of ff when encountering files greater than or equal to 2 Gbyte ( 2**31 bytes). FILES
/etc/default/fs default local file system type. Default values can be set for the following flags in /etc/default/fs. For example: LOCAL=ufs LOCAL The default partition for a command if no FSType is specified. /etc/vfstab list of default parameters for each file system ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
find(1), ncheck(1M), stat(2), vfstab(4), attributes(5), largefile(5) Manual pages for the FSType-specific modules of ff. NOTES
This command may not be supported for all FSTypes. The -a, -m, and -c flags examine the st_atime, st_mtime, and st_ctime fields of the stat structure respectively. (See stat(2).) SunOS 5.10 10 Feb 1997 ff(1M)
All times are GMT -4. The time now is 04:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy