Computing.Net > Forums > Programming > Unix scripting

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Unix scripting

Reply to Message Icon

Original Message
Name: vande
Date: April 9, 2008 at 10:45:49 Pacific
Subject: Unix scripting
OS: Windows xp, Windows
CPU/Ram: 2.4 quad core Intel
Model/Manufacturer: Dell, Dell, Dell
Comment:

Im doing some unix scripting and would like to, based off a file input calculate date. What we have is what is called infile in the script it reads certain fields within this "infile" the infile is just a txt document set so that our script can read from it to determine which files to delete or when to delete them. Right now we have prev-year= expr date +%Y -1 then throughout the code it use this math to determine if it needs to delete files and it gets its answer if the file date is +%Y -1 and true well we have more detail within there but for now ou should get the idea. I want to add file directories and file names to the master list also a new filed # of days to deletion then based off if the file has # of days then it will calculate thos days stated and delete if current date compared to deletion date is meet. Now i went to research date arithmetic and it was helpful but i dont just want to do this i want to have program read # of days till deletion and base it off that. Well that makes me think now how is it going to count down or know that 1 day went by 2 days three etc...

Learning in progress..........


Report Offensive Message For Removal


Response Number 1
Name: ghostdog
Date: April 9, 2008 at 16:58:49 Pacific
Reply: (edit)

what Unix platform are you in ? do you have GNU date and any other GNU tools eg Gawk?


Report Offensive Follow Up For Removal

Response Number 2
Name: Razor2.3
Date: April 9, 2008 at 17:25:16 Pacific
Reply: (edit)

Well, at the very least, he has AWK. It's one of two scripting environments guaranteed in POSIX.


Report Offensive Follow Up For Removal

Response Number 3
Name: vande
Date: April 9, 2008 at 17:26:04 Pacific
Reply: (edit)

I have ksh right now well thats what the script calls at the beginnning. What i need to do is create #of days until deletion and compare that to todays date however #of days until deletion sometimes will be 90 then when i compare 90 days from today like todays date -90 days i get negative number how do i make it go into the previous month?

Learning in progress..........


Report Offensive Follow Up For Removal

Response Number 4
Name: vande
Date: April 9, 2008 at 18:00:32 Pacific
Reply: (edit)

ok never mind cause i just went for a walk and thought about it. #of days will compare to #of days that went by from creation and i dont think this will be a problem lol

Learning in progress..........


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software