The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
How To Calculate krishna_sicsr Shell Programming and Scripting 3 03-21-2009 01:49 PM
calculate from three files koti_rama Shell Programming and Scripting 5 01-08-2008 09:27 AM
How to calculate with awk whatisthis Shell Programming and Scripting 4 11-09-2005 12:39 PM
swap space / paging space aaronh AIX 2 05-19-2004 11:06 AM
pageing space vs swap space VeroL UNIX for Dummies Questions & Answers 1 01-22-2004 11:54 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-09-2008
za_7565 za_7565 is offline
Registered User
  
 

Join Date: Nov 2007
Location: ON, Canada
Posts: 16
calculate the space

Hi everyone,

I need to write a script to calculate the space for sub-folders under /home:

Here is the scanrio:

cd /home
drwxr-xr-x 57 root root 8192 Jan 22 16:13 home_1
drwxrwxrwx 69 root root 8192 Jan 29 10:36 home_2
drwxr-xr-x 97 root root 8192 Nov 21 14:40 home_3
drwxr-xr-x 80 root root 8192 Jan 30 13:38 home_4
dr-xr-xr-x 1 root root 1 Feb 9 13:14 home_5
dr-xr-xr-x 1 root root 1 Feb 9 13:14 home_6
dr-xr-xr-x 1 root root 1 Feb 9 13:14 home_6
dr-xr-xr-x 1 root root 1 Feb 9 13:14 home_7
.
.
.
goes upto

dr-xr-xr-x 1 root root 1 Feb 9 13:14 home_23
I need to cd to each home dir and check for all folders where owner is a number and calculate it's size using "du -sk" command.

# cd home_1

ls -l
drwxr-xr-x 16 16848 eaq 4096 Sep 10 08:22 khanbx0c
drwxr-xr-x 21 17341 eao 12288 Oct 29 2006 labatlx
drwxr-xr-x 6 lasisiog eal 4096 Feb 4 07:25 lasisiog
drwxr-xr-x 14 lecailpx eau 4096 May 2 2007 lecailpx
drwxr-xr-x 14 16460 eao 4096 Oct 21 13:03 littleax
drwxr-xr-x 28 logtrak eaq 8192 Jul 2 2007 logtrak
drwxr-xr-x 2 17480 eap 4096 Feb 17 2007 megrinan
drwxrwxrwx 64 navaraam eaq 12288 Feb 6 15:47 navaraam
drwxr-xr-x 31 17501 eac 8192 Jul 2 2007 olaqiaa
drwxrwxr-x 104 owback easdmm 94208 Feb 6 13:25 owback
drwxr-xr-x 14 16490 ehe 4096 Nov 30 2004 patvalza
drwxr-xr-x 33 sagazt qcd 8192 Jan 30 17:04 sagazt
drwxr-xr-x 9 sanniml ehh 4096 Oct 22 14:27 sanniml
drwxrwxr-x 2 root root 4096 Jul 21 2004 seismic
drwxr-xr-x 9 shehriih eqc 4096 Nov 21 2006 shehriih
drwxr-xr-x 2 ssglusr ssd_ssg 4096 Oct 4 2005 ssglusr
drwxr-xr-x 2 17602 ehh 4096 Jun 3 2007 suicmevs
drwxr-xr-x 6 17436 eap 4096 Apr 7 2007 suwaiiah
drwxr-sr-x 77 wasimx eaf 24576 Feb 6 15:28 wasimx
drwxr-xr-x 12 16504 ehd 4096 Oct 21 13:03 xiaojx
drwxr-xr-x 3 17309 eap 4096 Dec 5 2006 youngsj
drwxr-xr-x 37 17406 qst 12288 Apr 3 2007 zambraga
drwxr-xr-x 47 zarmm eag 12288 Feb 5 10:47 zarmm
drwxrwxr-x 49 16531 eao 16384 Jun 14 2007 zegdra0a

I need to capture home directories where owner is just a number:

example:
drwxr-xr-x 37 17406 qst 12288 Apr 3 2007 zambraga

than run du -sk on those one by one by using echo:

zambraga 131040

Any tips would be appreciated.
 

Bookmarks

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0