LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   copying files according to modification date and extension (https://www.linuxquestions.org/questions/linux-newbie-8/copying-files-according-to-modification-date-and-extension-853184/)

SriniKlr 12-30-2010 01:28 AM

copying files according to modification date and extension
 
Hi,

I am trying to find a command which will copy all the files in the folder with extension ".log" which is created one day before the current date.

By going through other threads in this forum I found the half solution to this problem :)

find /mnt/hd -mtime -1 -exec scp {} /mnt/usb \;

This command copying the all the files created one day before(not only *.log) to the /mnt/usb folder.

please let me know what is the modification required to above command.

Thanks you!!

EricTRA 12-30-2010 01:43 AM

Hi,

Have a look at the man page for find:
Code:

man find
in particular the -name parameter you can add to your command.

Kind regards,

Eric

SriniKlr 12-31-2010 04:36 AM

Quote:

Originally Posted by EricTRA (Post 4207426)
Hi,

Have a look at the man page for find:
Code:

man find
in particular the -name parameter you can add to your command.

Kind regards,

Eric

Hi,

Thanks for the Advice. I am able to figure out answer to my question from the man page. But getting some error message with this command

#find /mnt/hd/ -mtime -1 -name "*.log" -exec scp {} /mnt/usb/ \;
find: scp: No such file or directory
find: scp: No such file or directory
find: scp: No such file or directory

But the command works fine without scp. Not able to figure out what is going wrong here!!!

# find /mnt/hd/ -mtime -1 -name "*.log"
/mnt/hd/dbg_34.log
/mnt/hd/dbg_12.log
/mnt/hd/dbg_14.log

Thanks

EricTRA 12-31-2010 04:41 AM

Hi,

Why are you using scp (secure copy which is part of ssh) to make a local copy to a USB stick? The error you get is because your system cannot find scp. Try with cp instead like this:
Code:

find /mnt/hd/ -mtime -1 -name "*.log" -exec cp {} /mnt/usb/ \;
Kind regards,

Eric

SriniKlr 01-03-2011 03:42 AM

Quote:

Originally Posted by EricTRA (Post 4208576)
Hi,

Why are you using scp (secure copy which is part of ssh) to make a local copy to a USB stick? The error you get is because your system cannot find scp. Try with cp instead like this:
Code:

find /mnt/hd/ -mtime -1 -name "*.log" -exec cp {} /mnt/usb/ \;
Kind regards,

Eric

It worked. Thanks a lot Eric for the help :)

Regards,
Srini

EricTRA 01-03-2011 03:45 AM

Hi Srini,

Glad you got your solution. Enjoy Linux.

Kind regards,

Eric


All times are GMT -5. The time now is 10:27 AM.