![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Removing empty folders using 'find' | deTTo | UNIX for Dummies Questions & Answers | 5 | 04-21-2008 06:24 PM |
| Empty Files | DNAx86 | Shell Programming and Scripting | 3 | 04-18-2008 06:45 PM |
| how to find empty folders without using -empty | lasse | UNIX for Dummies Questions & Answers | 7 | 01-16-2008 11:30 PM |
| deleting the empty files | srivsn | Shell Programming and Scripting | 1 | 02-08-2006 03:39 AM |
| move files from folder thats are not empty | Steven | UNIX for Dummies Questions & Answers | 8 | 11-21-2001 07:05 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
How to find files not empty?
Is there any way, we can find files not empty? I know one can find empty files by using find with -size is equalled to 0.
Please let me know, how I can find files greater than 0 or any other size in number? |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
find . -type f -exec wc -l {} \; | awk '$1 > 0 { print $2 }'
|
|
#3
|
|||
|
|||
|
You can use the find command to find non-zero length files:
find path -type f ! -size 0 In most UNIX implementations, the -size expression can also be used to search for file sizes of exactly N bytes (-size Nc), greater-than N bytes (-size +Nc), and less-than N bytes (-size -Nc). The confusing thing is that the numeric following -size is, by default, 512-byte blocks not a byte count. The numeric must be followed by a 'c' for that. The following command will find files less than 2KB: find . -type f -size -2048c -print Conversely, for files greater than 2KB: find . -type f -size +2048c -print One note, the 512-byte block count does not directly translate into bytes. It's a long story. You can display a file's block usage with, under Solaris, ls -s. Stick to byte counts. Oh, yes, one more thing, you can search for a specific range by using multiple -size expressions as long as they can all be satisfied by a single file. For example, locate files larger than 2KB and less than 8KB (inclusive): find . -type f -size +2047c -size -8193c Last edited by hegemaro; 02-26-2006 at 06:24 AM. |
|||
| Google The UNIX and Linux Forums |