- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script help needed
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
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
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
тАО04-24-2009 04:24 AM
тАО04-24-2009 04:24 AM
Script help needed
I have a file which is actually an ls -lrt o/p of a particular directory like.
------------------
-rw-r--r-- 1 501 206 13 Mar 6 07:01 /var/archive/prodcomp/batchlog/tmpwrk_EXZPR00Bs.06rwc.03060702/tmpwrk_EXZPR00Bs.06rwc/startup_parms
146107 -rw-r--r-- 1 501 206 6 Mar 6 07:02 /var/archive/prodcomp/batchlog/tmpwrk_EXZPR00Bs.06rwc.03060702/tmpwrk_EXZPR00Bs.06rwc/runphase
146120 -rw-r--r-- 1 501 206 167 Mar 6 07:01 /var/archive/prodcomp/batchlog/tmpwrk_EXZPR00Bs.06rwc.03060702/tmpwrk_EXZPR00Bs.06rwc/parfile
146202 -rw-r--r-- 1 501 206 6 Mar 6 07:02 /var/archive/prodcomp/batchlog/tmpwrk_EXZPR00Bs.06rwc.03060702/tmpwrk_EXZPR00Bs.06rwc/smd_jobid
-----------------
I just want to know how to find out how many files are getting created on each and every day in the particular directory.
thanks for the answers
Regards
Dev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2009 04:47 AM
тАО04-24-2009 04:47 AM
Re: Script help needed
Best to run with cron once a day.
cd
ls -1 | wc -l | mailx -s "daily file number report"
Run it the next day and do the math.
You can get more elaborate if you wish, but that is the basis.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2009 04:51 AM
тАО04-24-2009 04:51 AM
Re: Script help needed
# cat ./tally
#!/usr/bin/perl
use strict;
use warnings;
my (@F, %day);
while (<>) {
next unless /^(-|d|l)/;
@F = split;
$day{sprintf "%3s %02d", $F[5], $F[6]}++
}
for (sort keys %day) {
print $_, ' = ', $day{$_}, "\n";
}
...
Run as:
# ./tally file
...or:
# ls -l /path | ./tally
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2009 05:01 AM
тАО04-24-2009 05:01 AM
Re: Script help needed
find /var/archive/prodcomp/batchlog ! -type d -exec ls -lrt -print {} \; > /home/xosdj001/files
for getting the o/p in the files, now in the same file I want to know for each and every day how may files and are getting created(count) and what is the total size of within one day is getting generated.Which sud give me an o/p like:-
=============
Day Files_Generated Tot_siz_files
May 6 20 300 MB
May 7 15 250 MB
May 8 9 75 MB
.
.
.
.
=============
Thanks again
Regards
Dev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2009 05:58 AM
тАО04-24-2009 05:58 AM
Re: Script help needed
Add this script to your crontab to run daily and this script keeps updated copy of filesizes in bytes - convert to MB if you need by modifying the script.
echo "==============================================" > /tmp/file_list
echo "Day \t Files_Generated \t Tot_siz_files " >> /tmp/file_list
echo "==============================================" >> /tmp/file_list
for i in `ls -lrt /home/xosdj001/files | awk '{print $6}'| uniq`
do
for j in `ls -lrt /home/xosdj001/files | grep $i | awk '{print $7}'| uniq`
do
SUM=`ls -lrt /home/xosdj001/files | grep "$i" |awk '{sum = sum + $5} END {print sum}'`
NO=`ls -lrt /home/xosdj001/files | grep "$i" | wc -l`
echo "$i $j \t $NO \t\t $SUM" >> /tmp/file_list
done
done
echo "==============================================" >> /tmp/file_list
Cheers !!
Vinod
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2009 06:04 AM
тАО04-24-2009 06:04 AM
Re: Script help needed
# cat /tmp/file_list
==============================================
Day Files_Generated Tot_siz_files
==============================================
Mar 17 1 256
Apr 23 45 536421
Apr 24 45 536449
==============================================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2009 06:25 AM
тАО04-24-2009 06:25 AM
Re: Script help needed
> I want to know for each and every day how may files and are getting created(count) and what is the total size of within one day is getting generated.
You _really_ should ask what you _really_ want at the onset. Use:
# cat ./tally
#!/usr/bin/perl
use strict;
use warnings;
my ( @F, $n, $sz, $key, %day );
while (<>) {
next unless /^(-|d|l)/;
@F = split;
$key = sprintf "%3s %02d", $F[5], $F[6];
$n = $sz = 0;
if ( exists $day{$key} ) {
$n = $day{$key}[0];
$sz = $day{$key}[1];
}
$n++;
$sz += $F[4];
$day{$key} = [ $n, $sz ];
}
for $key ( sort keys %day ) {
print $key, ' = ', $day{$key}[0], " -> ", $day{$key}[1], "\n";
}
...run as:
# ./tally file
Your output will look like:
Apr 01 = 5 -> 1387253
Apr 16 = 1 -> 100
Apr 17 = 1 -> 1024
Apr 19 = 2 -> 8218
Apr 23 = 3 -> 2964
Apr 24 = 1 -> 51366
Apr 29 = 1 -> 590
Aug 17 = 2 -> 2458
Feb 02 = 1 -> 104
Feb 14 = 2 -> 102792
Feb 17 = 1 -> 8192
Feb 23 = 1 -> 8192
Feb 29 = 1 -> 738
Jul 17 = 1 -> 266
Jul 29 = 1 -> 8192
Jun 29 = 2 -> 192
Mar 11 = 3 -> 1372132
Nov 11 = 2 -> 7651
Nov 14 = 1 -> 965
Oct 10 = 2 -> 290749
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2009 10:49 AM
тАО04-25-2009 10:49 AM
Re: Script help needed
This version makes the formatting changes including the output in MB you wanted:
# cat ./tally
#!/usr/bin/perl
use strict;
use warnings;
my (@F, $n, $sz, $key, %day);
while (<>) {
next unless /^(-|d|l)/;
@F = split;
$key = sprintf "%3s %02d", $F[5], $F[6];
$n = $sz = 0;
if ( exists $day{$key} ) {
$n = $day{$key}[0];
$sz = $day{$key}[1];
}
$n++;
$sz+=$F[4];
$day{$key} = [ $n, $sz ];
}
print "Day #Files Total_Size\n------ ------ ----------\n";
for $key (sort keys %day) {
printf "%s %6d %7.0f MB\n" ,$key, $day{$key}[0], $day{$key}[1]/1024/1024;
}
1;
# cat ./tally
Your output will look like:
Day #Files Total_Size
------ ------ ----------
Apr 16 8 0 MB
Apr 17 6 103 MB
Apr 18 3 53 MB
Apr 19 6 148 MB
Regards!
...JRF...