![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| get file size by date for a directory | ibaboomer | Shell Programming and Scripting | 1 | 09-15-2009 09:04 AM |
| command to reduce size of file/directory??? | nsharath | Shell Programming and Scripting | 2 | 01-21-2009 12:11 PM |
| How to compare size of two file which is in one directory | Aditya.Gurgaon | Shell Programming and Scripting | 1 | 01-08-2009 06:28 AM |
| checking directory size in the text file | G.K.K | Shell Programming and Scripting | 5 | 09-25-2008 11:23 AM |
| How to know size of file in a directory | kittusri9 | Shell Programming and Scripting | 1 | 04-28-2008 09:43 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hello. I do have a problem. The statement sounds like this: Given a directory, find all subdirectories (regardless of depth) which contain a file that has more than a half of the size of the respective subdirectory. I've tried to solve this in many ways, but all I came up with is half solutions. One would be trying this: Code:
find folder -type f -size +x where I would search for the size of each file, x being a variable, but this should be applied to each file. Another one, which seems not to work, would be this: Code:
for i in $(ls $1); do if [ -d $i ]; then echo $i; fi; done but still, i should search for each file and compare it with the directory. trying Code:
ls -R folder would be a solution, but I can't connect it with another command. or this one: Code:
for i in `find $1 type -d'
do
for j in `find $i type -f -size +(size($i))` // in blocks
do
echo j;
done
done
where, size($i) would be the size converted in blocks, and I didn't know how to do that. Thanks Last edited by WorkOfArt; 10-13-2009 at 09:23 AM.. |
| Bits Awarded / Charged to WorkOfArt for this Post | |||
| Date | User | Comment | Amount |
| 10-13-2009 | thegeek | Good to see that what he have tried to achieve the solution | 500 |
|
||||
|
It is great to see your question, i would greatly appreciate it. Here is the answer for you. Code:
ls -lh total 28K -rw------- 1 thegeek learner 18K Oct 10 05:52 feed -rw------- 1 thegeek learner 2.5K Oct 10 05:51 feedbacks -rw------- 1 thegeek learner 32 Oct 10 05:51 tttt So only the feed is the file whose size is 18k which is more than the half of the dir size which is 28K. To get that, following is the script., Code:
for i in `find . -type d`
do
echo $i
dirsize=`du -s $i | cut -f1`
echo $dirsize
find $i -size +$dirsize -type f
done
If it requires a little edit for your requirement, go a head and do it. But this would help you in achieving the core part of what you would want. |
![]() |
| Bookmarks |
| Tags |
| files, folders, ls, shell |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|