ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
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.
Hi,
Is there any command combination or a bash shell script to copy directory/file according to date of modification or creation.
Suppose i want to copy files/dir creater on 2007-Feb-11 in to some directory. How to do this?
FYI, I'd use mtime .. there's no such thing as 'creation' time in Unix.
Quote:
Three fields in the inode structure contain the last access, change, and modification times: atime, ctime, and mtime. The atime field is updated each time the pointer to the file's data blocks is followed and the file's data is read. The mtime field is updated each time the file's data changes. The ctime field is updated each time the file's inode changes. The ctime is not creation time; there is no way under standard Unix to find a file's creation time.
$ find /path/to/some/folder/* -type d -mtime -3 -exec scp {} jane@192.168.2.22:/home/jane/test/ \;
/path/to/some/folder/dir1: not a regular file
/path/to/some/folder/dir2: not a regular file
/path/to/some/folder/dir3: not a regular file
This was the out put i got.It is considering as a file but not directories. Files are getting copied but not directories. How to copy directories?
No, not just copying with scp. It should find the latest files/dir modified in src remote machine and then copy them into dest local machine. This action must be performed from the local machine.
Look into rsync. Not sure if you can do it in one line like that; ie its normally just 2 machines involved, src, dest.
If not, you'll either have to setup rsync on the 2 machines you want to update between, or find a way of generating the expected filenames and use scp as described.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.