Welcome to the most active Linux Forum on the web.
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 10-15-2004, 05:39 AM   #1
LQ Newbie
Registered: Oct 2004
Posts: 1

Rep: Reputation: 0
Script to Move files


I want to write a shell script which will look into the directory for the files which has been modified / updated on today's date and move them into the directory which has been named based on Today's date.

For ex: Suppose that todays date is OCT 15, then it will select all files having date modified/created as OCT 15 and then make a dir OCT 15 and move all these files to this directory.

I am able to get date and make directory accordingly using following cmd

d=`date "+%b %d"
mkdir $d

But I am not able to select files based on date and move them into this folder. Can anyone please tell me how to do that?

Old 10-15-2004, 08:53 AM   #2
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
Here ya go! The modification date is at less than one day ( today )
with the command: -mtime -1


d=`date "+%b%d"`
mkdir /home/$d

cd /home/stuff
find . -depth -type f -name '*' -mtime -1 -exec mv {} /home/$d \;


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
Script to find all picture files on a HDD and move them scoops98 Linux - General 8 02-27-2007 02:40 AM
How can I move files from a host to another in a script eantoranz Linux - Networking 7 08-12-2005 02:39 PM
how to write a script to move files from one directory to another myeire Linux - Newbie 7 02-25-2005 10:01 AM
making a script that will move a file or files in a trash folder Paxmaster Programming 5 12-12-2004 06:00 PM
Need help with script to move files over a NFS Reggy Programming 1 03-19-2004 06:12 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:35 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