The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
No space on /dev/hd 1/42 ibqti SCO 1 11-09-2007 01:53 PM
swap space / paging space aaronh AIX 2 05-19-2004 07:06 AM
how much space? pgas UNIX for Dummies Questions & Answers 1 04-06-2004 08:03 AM
pageing space vs swap space VeroL UNIX for Dummies Questions & Answers 1 01-22-2004 07:54 AM
More space grep UNIX for Dummies Questions & Answers 2 12-02-2002 11:08 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-27-2005
Registered User
 

Join Date: Jan 2005
Posts: 5
space hog

How can I find the hog AND list files edited in the past day?

I have used du -ks *|sort -nr|pg --to find hog listed in kilobytes

I know find ./ -mtime +1 -- will find files modified in the past day.


How can I combine them or what would be a better way?

The reason for this is that I had a dir getting full and within that directory it was pretty even accross 10 directories as to the highest Mb amount. Wanted to narrow down where to look for any log files or the culprit that most recently grew too large.


-Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-27-2005
Registered User
 

Join Date: Nov 2001
Location: Flint, MI
Posts: 164
Maybe this will help:
Find Command
Reply With Quote
  #3 (permalink)  
Old 01-27-2005
finster's Avatar
Registered User
 

Join Date: Nov 2002
Location: USA
Posts: 75
Thanks for the link but I still am having the problem......not able to find the hog AND list files edited in the past day?
Reply With Quote
  #4 (permalink)  
Old 01-27-2005
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
I'm still not totally sure how you want the formatting of the final report.

Also, you need -mtime -1 in order to show files modified in the last 24 hours (i.e. a day ago or less).

A basic idea would be something like....
Code:
#!/bin/sh

du -ks * | sort -nr | while read size hog
do
   # Display size of dir/file
   echo "Current Hog - $hog ($size):"
   # Show listing of files modified a day ago or less
   find $hog -mtime -1 -exec ls -l {} \;
done
Although the formatting in the output will need tweaking to your requirements.

Cheers
ZB
Reply With Quote
  #5 (permalink)  
Old 01-27-2005
Registered User
 

Join Date: Jan 2005
Posts: 5
Can u explain:

find $hog -mtime -1 -exec ls -l {} \;

I transfered a large file just before executing script so it could be considered a growing hog within 1 day as a test (Al.v1.4.3.410.Retail.rar)
Here is my output:

$ du -ks *|sort -nr|pg
217208 bac.tar
130664 16.1.0.30.tar
86583 ciagent_sms
3280 Al.v1.4.3.410.Retail.rar
3 test
2 house
1 test2.txt.gz
1 test2.txt
1 test1.txt
1 test.sh
1 test.csv
1 script.sh
1 private
1 one
1 hog1
1 hog.sh
1 files.tar.Z
1 dir_link
1 dead.letter
1 date.txt
1 csv_link
0 perm
$
$

HERE IT YOUR SCRIPT:

$ hog.sh
Current Hog - bac.tar (217208):
Current Hog - 16.1.0.30.tar (130664):
Current Hog - ciagent_sms (86583):
Current Hog - Al.v1.4.3.410.Retail.rar (3280):
-rw-r--r-- 1 joek staff 3344362 Jan 27 15:34 Alcohol.120%.v1.4.3.410.Retail.rar
Current Hog - test (3):
Current Hog - house (2):
Current Hog - test2.txt.gz (1):
Current Hog - test2.txt (1):
Current Hog - test1.txt (1):
Current Hog - test.sh (1):
Current Hog - test.csv (1):
Current Hog - script.sh (1):
Current Hog - private (1):
Current Hog - one (1):
Current Hog - hog1 (1):
-rw-r--r-- 1 joek staff 234 Jan 27 15:25 hog1
Current Hog - hog.sh (1):
-rwxrwxrwx 1 joek staff 224 Jan 27 15:48 hog.sh
Current Hog - files.tar.Z (1):
Current Hog - dir_link (1):
Current Hog - dead.letter (1):
-rw------- 1 joek staff 301 Jan 27 11:13 dead.letter
Current Hog - date.txt (1):
Current Hog - csv_link (1):
Current Hog - perm (0):

It looks like it works, but I would like to understand how? How does the last line work? (find $hog -mtime -1 -exec ls -l {} \

Also, when it searches for the hog for the past day could I format the output using - awk '{print $5,$NF,$6}' so it only displays column 5,6 and the last column of the "ls -l" command (size,filename, date).

I tried to insert that instead of the -exec comand with no luck.


-Thanks
Reply With Quote
  #6 (permalink)  
Old 01-27-2005
bhargav's Avatar
Registered User
 

Join Date: Sep 2004
Location: USA
Posts: 511
I did some thing like this ...


Code:
find $hog -mtime -1 | xargs ls -l | xargs | tr -s " " | awk ' { print $5,$NF,$6 } '
Reply With Quote
Google UNIX.COM
Reply

Tags
mtime

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0