- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- finding directories of certain size
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 08:58 AM
03-01-2007 08:58 AM
i tried
find . -type d -size +$1c -print
but it doesn't work.
i have a hint that it may be done with du command but no idea how.
anyone has an idea?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 09:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 09:09 AM
03-01-2007 09:09 AM
Re: finding directories of certain size
find . -type d -size +${1}c
should work, proovided that you pass the size as ${1} into your script.
You may want the total size of the fimes in a directory and for that indeed, du is more appropriate but you will have to apply an additional filter to limit the sizes. Note that du reports in 512-byte blocks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 09:26 AM
03-01-2007 09:26 AM
Re: finding directories of certain size
i will give the size as a parameter to the program. let's assume that size type is bytes.
i will run the program like:
./program.sh 10000
and the program's output will be only the directory's names, which are larger than 10000 bytes. the output shall not include the sizes.
the search for the directories should start from the current directory and recursively search all other subdirectories...
the find command does not work properly so i need a script with du command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 09:57 AM
03-01-2007 09:57 AM
Re: finding directories of certain size
#!/usr/bin/sh
typeset -i STAT=${?}
typeset PROG=${0}
if [[ ${#} -ge 1 ]]
then
du | awk -v sz=${1} '{if (($1 + 0) * 512 >= sz) {print $2}}'
STAT=${?}
else
echo "Usage: ${PROG} size" >&2
STAT=255
fi
exit ${STAT}
Note that the actual granulariry is 512 bytes -- but how much do you want for free?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 10:02 AM
03-01-2007 10:02 AM
Re: finding directories of certain size
> the find command does not work properly so i need a script with du command
See my original suggestion using 'du' and an 'awk' pipe, above.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 11:16 AM
03-01-2007 11:16 AM
Re: finding directories of certain size
but there are some points I do not undertand.
du -x /path|awk '{if ($1 > 10000) {print}}'
is it possible if I don't write the /path?
because program may run in different directories, not in a fixed directory and it's subdirectories...
and I don't understand what the parameter $1 stands for. in my program, I need to enter size as a paramater to the $1. if I enter 12000 the statement is ...if(5000 > 10000) and this doesnt make any sense. can you help please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 11:22 AM
03-01-2007 11:22 AM
Re: finding directories of certain size
...if(12000 > 10000)... :=)
I need a list of all directory names which are largen than 12000 byte, from the current directory to all subdirectories, recursively...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 11:29 AM
03-01-2007 11:29 AM
Re: finding directories of certain size
Clay and I have offered the same thinking. His script is a bit more refined for continued use. Mine is designed for command line use.
You asked:
> is it possible if I don't write the /path?
because program may run in different directories, not in a fixed directory and it's subdirectories...
Yes, change '/path' to respresent whatever directory you want to begin your search in.
> ...and I don't understand what the parameter $1 stands for.
The "$1" is 'awk's notation for the first field of a record. In the 'du' output piped to it, that's the size (in *1K blocks*).
Clay's script better accomodates your need. He converts the default 512-byte block count to bytes and allows you to pass the threshold as an argument.
Regards!
...JRF...
in my program, I need to enter size as a paramater to the $1. if I enter 12000 the statement is ...if(5000 > 10000) and this doesnt make any sense. can you help please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 11:54 AM
03-01-2007 11:54 AM
Re: finding directories of certain size
I am really a newbie, started to learn shell a couple of days ago. So I can't use Mr. Clay's code, too complicated for me, but thanks anyway. :)
du -x .|awk '{if ($1 > $2) {print}}' suits for me. I tried it and it seems working fine. I am grateful for your help. Thanks :)...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2007 06:49 PM
03-01-2007 06:49 PM
Re: finding directories of certain size
Welcome to itrc and this is the really greatest forum probably that you have never
seen before...i have been learning since
i registered here and still keeping to learn.
Anyway,here is the script normally does not match your actual question but may need such a kind script in the future.
more warn_user.sh
#######################################################################
#Kullanicilarin egreksiz dosyalarini silmesi icin uyari mesai atar!!!!#
#Cem Tugrul(1480)!!!BAC-I dept #
#######################################################################
#!/usr/bin/ksh
cd /users;
if [ $? -ne 0 ]
then
echo "/users directory si bulunamadi.."
exit 1
fi
for user in `du -ks * |sort -n|egrep -v "bsp|rvs|hp|oracle|picolog|baycom|pic412|mailuser|htnm"|awk '{if ($1 >= 50000) print $2 }'`
do
echo "LUTFEN BaaN uzerindeki gereksiz dosyalarinizi SILINIZ!!!Bilgi icin--->Cem Tugrul(1480)"|mailx -s "BaaN Kullanimi" $user@mntra
nkmail01
done
#script explanation in Turkish!!!
Yukarıdaki script bsp,rvs vb kullanıcıların dısındaki kullanıcıların home directory lerinin size 50Mb astiginda onları gereksiz dosyları silmeleri konusunda onlara mail atar.
Again Welcome,
Tekrar Hosgeldin,
Good Luck,
İyi Sanslar,