View the Most Wanted LQ Wiki articles.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 05-04-2009, 12:37 AM   #1
LQ Newbie
Registered: May 2009
Posts: 1

Rep: Reputation: 0
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.

Last edited by Urik; 05-04-2009 at 12:49 AM.
Old 05-04-2009, 01:46 AM   #2
Senior Member
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
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.
Old 05-04-2009, 02:23 AM   #3
LQ Newbie
Registered: Apr 2008
Distribution: RedHat, CentOS, Ubuntu
Posts: 6

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

have fun!
Old 05-04-2009, 06:59 AM   #4
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 734Reputation: 734Reputation: 734Reputation: 734Reputation: 734Reputation: 734Reputation: 734
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 and get the Bash Guide for Beginners


script, shell

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to ssh from a shell script ? For ppl who can write shell scripts. thefountainhead100 Programming 14 10-22-2008 06:24 AM
help with execute mulitple shell script within shell script ufmale Programming 6 09-13-2008 12:21 AM
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 02:34 PM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM

All times are GMT -5. The time now is 12:04 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration