![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Space issue with Directory | siba.s.nayak | UNIX for Dummies Questions & Answers | 1 | 06-03-2008 07:14 AM |
| How do I increase disk space available to a directory? | rhack | UNIX for Dummies Questions & Answers | 2 | 10-21-2005 11:54 AM |
| Space Used by Directory Tree | johnk99 | Filesystems, Disks and Memory | 1 | 07-22-2002 12:30 PM |
| Check directory space? | lesstjm | Shell Programming and Scripting | 3 | 04-19-2002 09:10 AM |
| Space left under current directory | SmartJuniorUnix | UNIX for Dummies Questions & Answers | 2 | 06-26-2001 11:32 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
I looked into my script and saw that "grep" is doing fine a job by capturing the names of directories with space. The awk is not transferring the names correctly. It cuts the directory field until it encounters a space. I am thinking of doing some kind of substitution. Can anyone help me now?
Thanks in advance, Nitin ![]() |
|
||||
|
my guess in your awk statement you are only pasing $1 if you also pass $2 you will get the 2nd word if the dir. either that or you can change the field seperator.
OR use $1 for the most part and tos an if -d to see if your awk vaiable is valid if yes then delte if no add $2 rerun directory check. |
|
|||||
|
You might try changing your field separator
environment variable to somthing like... export FS=":" By default, the field separator is whitespace. I haven't actually tried this with awk but I believe awk will assume $1 = "My" and $2 = "Mail" using whatever the field separator is. If you have names with ":" in them then try a different character. |
|
||||
|
Well, I have to say that there may be a more practical way of doing what you want... I mean, why not just have something which prunes away files that are over say 30-days old?...
Something like: Code:
#!/usr/bin/perl
$volume=$ARGV[0];
@dirs=`find /usr/$volume -name Trash`;
$curtime=time();
$number_days=30;
foreach(@dirs)
{
chomp();
opendir(DIR,$_);
while($fname=readdir(DIR))
{
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)=stat($fname};
# 60 seconds, 60 minutes, 24 hours
if($ctime < $curtime-(60*60*24*$number_days))
{
unlink $fname;
}
}
}
- dEvNuL added code tags for readability --oombera Last edited by oombera; 02-20-2004 at 11:41 AM.. |
|
|||||
|
I had thought of deleting all the files older than a week. But, Netscape (mail server) creates some control files (e.g. __GENNAME__, __lock__, etc.) in the Trash directory of users. If removed users won't be able to see the Folders at client end (and raise hell on me!
). I could look into your script and tell it not to delete the files starting with "__".Thanks a lot though. ![]() |
![]() |
| Bookmarks |
| Tags |
| mtime |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|