Help needed in ksh scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed in ksh scripting
# 1  
Old 01-14-2011
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
# 2  
Old 01-14-2011
Tools Yes, you can create a script

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?
# 3  
Old 01-14-2011
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
# 4  
Old 01-19-2011
3) find . -type f | wc -l

4) du -sk *

can any one help me for 1, 2 and 5?
# 5  
Old 01-19-2011
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.
# 6  
Old 01-19-2011
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 ----------

Code:
 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

# 7  
Old 01-19-2011
ls does not read standard input. Assuming bash or ksh try:
ls -ltr $(find . -type f -mtime +2)
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed in scripting

Hi Guys, I need help in scripting out the below : this is a sample data i have in my file: jobname type 8:00:00 AM I need to remove the ":00" from the time field alone. Thanks in advance for all ur help (8 Replies)
Discussion started by: a12ka4
8 Replies

2. Shell Programming and Scripting

Scripting help needed

Hi All, I have a conf file and it has two entries seperated by comma, look like :- best1,ls /opt/bmc/Patrol3/*/best1 ......, ....................... In which "Best1" is the product name and "ls /opt/bmc/Patrol3/*/best1" is the way to find the product version of Best1 in that particular... (5 Replies)
Discussion started by: Renjesh
5 Replies

3. Homework & Coursework Questions

Scripting needed

Hi, My task is to check the file test.txt every 15 min from Mon-Fri 9:00AM - 6:00PM. We get this file from our mainframes, every 15 min it will update the same file. My task is to compare file timestamp with current system time stamp and check if the file is updated or not. If the file doesn't... (0 Replies)
Discussion started by: chinniforu2003
0 Replies

4. Shell Programming and Scripting

Help needed with scripting.

Hello Friends, I am very new to scripting and currently have come across a situation where I need to create a UNIX script which would look for certain text in a file and then email me if it finds it. I am trying to trouble shoot an issue with our internet websites and I need to know when I... (1 Reply)
Discussion started by: mahive
1 Replies

5. Shell Programming and Scripting

ksh scripting help needed.

I am trying to create a script to manipulate numerous file and at first I thought it would be a simple task but at this point i am ready to break my computer! I am new to unix scripting so hopefully someone out there thinks this is super easy and can help me out! A sample of the problem file is... (2 Replies)
Discussion started by: theqcup
2 Replies

6. UNIX for Dummies Questions & Answers

sh scripting! Help Needed

Hello fellas or ladies. I am new on this site and new to the unix operating system. I have been working with UNIX and i love it so far, i learned some stuff and most of the beneficiary command but I need help renaming all the files in my directory and doing them one by one is just tiring. is there... (3 Replies)
Discussion started by: keyboardkowboy
3 Replies

7. Shell Programming and Scripting

sh scripting! Help Needed

Hello fellas or ladies. I am new on this site and new to the unix operating system. I have been working with UNIX and i love it so far, i learned some stuff and most of the beneficiary command but I need help renaming all the files in my directory and doing them one by one is just tiring.... (1 Reply)
Discussion started by: keyboardkowboy
1 Replies

8. Shell Programming and Scripting

Help needed - ksh shell scripting

Hi all, i m new to Unix shell scripting(ksh) i have a requirement, can anyone help me out in this.. spec: i need to move all the files landing in "X" directory to "Y" directory automatically everyday at a particular time.. (5 Replies)
Discussion started by: subbu
5 Replies

9. Shell Programming and Scripting

little scripting help needed!!

guys i need bit of help!! i am writing a script which finds files that have not been accessed for a no of days and delete those files...the no of days value is inputted at the command line.... i am using the following : find $1 -atime +7 -exec rm -i in the second step i want to copy all... (2 Replies)
Discussion started by: vats
2 Replies
Login or Register to Ask a Question