Operating System - HP-UX
1748008 Members
4323 Online
108757 Solutions
New Discussion

Re: Modify a script to work on bash shell rather than ksh

 
SOLVED
Go to solution
NDO
Super Advisor

Re: Modify a script to work on bash shell rather than ksh

du returns: single digit numbers, and find returns: wc -l
NDO
Super Advisor

Re: Modify a script to work on bash shell rather than ksh

 

 

Now its working I have used the following:

 

echo "$dir $(find $dir -type f |wc -l)"

 

Dennis Handly
Acclaimed Contributor

Re: Modify a script to work on bash shell rather than ksh

>du returns: single digit numbers

 

As I said, du(1) returns a line for every arg and subdirectory.

NDO
Super Advisor

Re: Modify a script to work on bash shell rather than ksh

its now working fine, I put in the cron to run every hour, but I what I would like now is to insert those figures in some king database or spreadsheet, to make statiscs on hourly and daily basis.

Dennis Handly
Acclaimed Contributor

Re: Modify a script to work on bash shell rather than ksh

>is to insert those figures in some kind database or spreadsheet, to make statistics on hourly and daily basis.

 

Well, you could create a CSV by inserting a "," between the name and count.

You probably also want to add a simple timestamp as another field:

echo "$(date +"%Y-%m-%d:%H:%M") ..."


NDO
Super Advisor

Re: Modify a script to work on bash shell rather than ksh

please I am not quite sure how to create a csv on that line, if I undestood correctly
Dennis Handly
Acclaimed Contributor

Re: Modify a script to work on bash shell rather than ksh

>I am not quite sure how to create a csv on that line,

 

Add a title line before your for-loop

echo "Date,Directory,File_count"

 

Then in the loop:

echo "$(date +"%Y-%m-%d:%H:%M"),$dir,$(find $dir -type d | wc -l)"