Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
04-21-2011, 04:26 AM
|
#1
|
LQ Newbie
Registered: Apr 2011
Posts: 2
Rep:
|
unix shell script for housekeeping
Hi everyone,
i have to write a shell script that will delete all the .dat files in /var/oracle/etl/incoming which the created date of the file is 7 days before the currrent date.
since i'm a newbie to unix, i have no idea how to write it!!! 
kindly pls help buddies....
thanks in advance!!!!
|
|
|
04-21-2011, 04:30 AM
|
#2
|
Member
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Rep:
|
so if i'm getting it right, you have to delete all .dat files in that folder which are 7 days old? (7 days or less or 7 days or more)??
|
|
|
04-21-2011, 04:44 AM
|
#3
|
Member
Registered: Jun 2006
Location: Tlv
Distribution: Arch!
Posts: 120
Rep:
|
Code:
find /var/oracle/etl/incoming '*.dat' -mtime +7 -exec rm {} \;
Last edited by X.Cyclop; 04-21-2011 at 04:48 AM.
|
|
1 members found this post helpful.
|
04-21-2011, 04:58 AM
|
#4
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
A shell script is essentially a series of commands. In this case you only need one command, as already given:
Quote:
Originally Posted by X.Cyclop
Code:
find /var/oracle/etl/incoming '*.dat' -mtime +7 -exec rm {} \;
|
With correction and safety:
Code:
find /var/oracle/etl/incoming -name '*.dat' -mtime +7 -exec echo rm {} \;
Remove the echo when you are confident it is going to remove the files you want to remove.
|
|
3 members found this post helpful.
|
04-21-2011, 07:38 AM
|
#5
|
Moderator
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,976
|
Hi,
Welcome to LQ!
Quote:
Originally Posted by netha
Hi everyone,
i have to write a shell script that will delete all the .dat files in /var/oracle/etl/incoming which the created date of the file is 7 days before the currrent date.
since i'm a newbie to unix, i have no idea how to write it!!! 
kindly pls help buddies....
thanks in advance!!!!
|
Sure sounds like homework to me. What have you done to find a solution to the problem? Other than to post here.
We will aid you when you help yourself to a solution. Provide us with what you have attempted and then maybe someone will be able to assist. To spoon feed member answers for homework helps no one, especially the requester.
As the LQ Rules state;
Quote:
Do not expect LQ members to do your homework - you will learn much more by doing it yourself.
|
FYI: I suggest that you look at 'How to Ask Questions the Smart Way' so in the future your queries provide information that will aid us in diagnosis of the problem.
For scripting I suggest that you look at 4,5 & 6 below.
Just a few links to aid you to gaining some understanding;
1 Linux Documentation Project
2 Rute Tutorial & Exposition
3 Linux Command Guide
4 Bash Beginners Guide
5 Bash Reference Manual
6 Advanced Bash-Scripting Guide
7 Linux Newbie Admin Guide
8 LinuxSelfHelp
9 Utimate Linux Newbie Guide
The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!
|
|
|
04-21-2011, 09:49 PM
|
#6
|
LQ Newbie
Registered: Apr 2011
Posts: 2
Original Poster
Rep:
|
Thank you all!!!
Quote:
Originally Posted by catkin
A shell script is essentially a series of commands. In this case you only need one command, as already given:
With correction and safety:
Code:
find /var/oracle/etl/incoming -name '*.dat' -mtime +7 -exec echo rm {} \;
Remove the echo when you are confident it is going to remove the files you want to remove.
|
rely appreciate wat u all have replied... Thank you!!!

|
|
|
04-22-2011, 08:16 AM
|
#7
|
LQ 5k Club
Registered: Sep 2009
Posts: 6,443
|
If the issue is solved, mark the thread as solved.
|
|
|
04-22-2011, 08:54 AM
|
#8
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
I'm with onebuck on the homework issue but a solution had already been offered
|
|
|
04-22-2011, 09:54 AM
|
#9
|
Moderator
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,976
|
Hi,
Too many members just shoot answers without considering consequences for the OP. Sure, answered but did the poster learn anything other than copy & paste?
As a member I would like to see others think about shot-gunning solutions. Would you want someone that could perform, possibly stumble while in training to learn or someone that gets the answer then graduates and then fails? I would not hire the latter!
There's a time for spoon feeding and a time to address a posters attempt at the tasks. Throwing out answers helps no one, not even the member who already knows the answer. Try to model your answer to help the poster to understand not flat out doing the task(s).
Quote:
Do not expect LQ members to do your homework - you will learn much more by doing it yourself.
|
This LQR is simple but justifiable, reasonable and should be the controlling factor when addressing homework so the poster can learn. We may need to assist yet not do it.

|
|
|
05-22-2012, 02:34 PM
|
#10
|
LQ Newbie
Registered: Dec 2011
Posts: 4
Rep: 
|
[SOLVED] unix shell script for housekeeping
In support of what Gary said, I believe the old adage about giving a fish to a man applies:
Give a man a fish and he will eat for a day.
Teach a man to fish and he will steal all of the big ones in your pond.
|
|
|
05-22-2012, 08:53 PM
|
#11
|
Member
Registered: Jul 2004
Location: Chennai, India
Posts: 952
|
Sure a student, but may be self study (of the Oracle 10G infrastructure)
http://linux.bigresource.com/General...JmDUpMIrG.html
Just following the link there for view replies points me back to LQ.
OK
Last edited by AnanthaP; 05-22-2012 at 09:18 PM.
|
|
|
All times are GMT -5. The time now is 06:34 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|