LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I need some Script Shell help please. (https://www.linuxquestions.org/questions/linux-newbie-8/i-need-some-script-shell-help-please-723452/)

Urik 05-04-2009 12:37 AM

I need some Shell Scripting help please.
 
So I need to make a script for college and I'm having a lot of trouble.
I'm supposed to make a script that gets two arguments. Both of them dates.
The script should search for all of the files that were last accessed on the date1, and replace such date with date2.
Let's say for example:
./script1 26/04/2009 03/05/2009

I thought about searching for all the files last accessed on that date using a find -ls | grep apr 26 .
However, is that the last accessed date? Or last modificated? And is there any better way to do that?
Obviously, after finding the files, how could I process all of them? Is there for processing each entry at the time of the search?
For example:
finds file1, fixes date, continues searching, finds file2, fixes date, continues searching...

Thanks guys.

hw-tph 05-04-2009 01:46 AM

We don't do people's homework here, sorry.

Start by actually reading the manual page for find (type man find), that's pretty much what you need.

jdros 05-04-2009 02:23 AM

All you need is:
- man find
- man touch
- some scripting :-)

have fun!

pixellany 05-04-2009 06:59 AM

As already noted, read up on the "find" command---there are many options.

Before attempting to write a script, be sure you know how the individual commands work. For example, find has specific options for the 3 different file times: Accessed, Modified, and Changed status.

I'm unclear on what you mean "replacing the date"---do you want to actually modify the properties of the file?

Finally, if you have not already read it, go to http://tldp.org and get the Bash Guide for Beginners


All times are GMT -5. The time now is 06:07 PM.