Help needed in ksh scripting

I got a task to do today, I want to write a script for the following

1) Archive log more than 2 days old
2) Number of days the current Archive logs present
3) Total number of archive logs
4) Size of each archive log
5) When was last successful backup happened?

Can I get a general script (Ksh) for this?

Thanks in advance

What have you done so far in this 5-part requirement.

The purpose of this forum is to provide guidance and assistance to unix users. We are not here to write programs for people and companies.

So, if you start on this, we are more than happy to offer guidance and suggestions. Or, are you looking to pay someone to write programming?

Thank you for replying Sir.

I dint ask you to write a program for me or I dint ask you the specific script.
All I need is a general script to start myself (like a similar sample script). I am totally new to scripting. Just looking for a sample ksh script.

Thank you

3) find . -type f | wc -l

4) du -sk *

can any one help me for 1, 2 and 5?

The task requirements are so vague that it is hard to reply. I thought that "archive" was an action that you were required to take on certain "log files". Now it seems that "archive" might be an adjective that describes certain files. I guess that the current directory contains nothing but "archive files"? If so maybe 5 is just:

ls -ltr | tail -1

1 is a real puzzle. It seems that you are supposed to do something to those files older than 2 days? But I can't tell what you need to do. My telepathy informs my that you should remove them. (Warning: I never win the lottery.)

find . -type f -mtime +2 | xargs rm

I'm doing a lot of guessing here. You get more responses when we don't need to guess.

5) yes, you are right. Just we have archive logs in it.
1) For now just they want to view 2 days old archive log - JUST to SEE
2)How old the first archive log is? (In days)

---------- Post updated at 02:28 PM ---------- Previous update was at 02:24 PM ----------

 find . -type f -mtime +2 | ls -ltr
total 4
drwxr-x---   2 oracle     dba             96 Jan 13 18:06 2011_01_12
drwxr-x---   2 oracle     dba             96 Jan 16 05:59 2011_01_13
drwxr-x---   2 oracle     dba             96 Jan 16 05:59 2011_01_14
drwxr-x---   2 oracle     dba             96 Jan 16 05:59 2011_01_15
drwxr-x---   2 oracle     dba           1024 Jan 18 18:07 2011_01_17
drwxr-x---   2 oracle     dba             96 Jan 18 18:07 2011_01_16
drwxr-x---   2 oracle     dba           1024 Jan 18 20:20 2011_01_18

I should get list of 2 days old files, but I am getting this output

ls does not read standard input. Assuming bash or ksh try:
ls -ltr $(find . -type f -mtime +2)

Got same output! :confused:

$ ls -ltr $(find . -type f -mtime +2)
total 4
drwxr-x---   2 oracle     dba             96 Jan 13 18:06 2011_01_12
drwxr-x---   2 oracle     dba             96 Jan 16 05:59 2011_01_13
drwxr-x---   2 oracle     dba             96 Jan 16 05:59 2011_01_14
drwxr-x---   2 oracle     dba             96 Jan 16 05:59 2011_01_15
drwxr-x---   2 oracle     dba           1024 Jan 18 18:07 2011_01_17
drwxr-x---   2 oracle     dba             96 Jan 18 18:07 2011_01_16
drwxr-x---   2 oracle     dba           1024 Jan 18 20:20 2011_01_18
 

Maybe you have no files that are that old. The find command then returns nothing and ls just prints the current directory. That directory you show has directories in it, not files. Try switching to: "-type d" on the find command to process directories instead of files. Aldo add a "d" switch to the ls command to display directories and not the content of directories.

ls -ldtr $(find . -type d -mtime +2)