LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 12-30-2010, 02:28 AM   #1
SriniKlr
LQ Newbie
 
Registered: Dec 2010
Posts: 13

Rep: Reputation: 0
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!!
 
Old 12-30-2010, 02:43 AM   #2
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
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
 
Old 12-31-2010, 05:36 AM   #3
SriniKlr
LQ Newbie
 
Registered: Dec 2010
Posts: 13

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by EricTRA View Post
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
 
Old 12-31-2010, 05:41 AM   #4
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
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
 
Old 01-03-2011, 04:42 AM   #5
SriniKlr
LQ Newbie
 
Registered: Dec 2010
Posts: 13

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by EricTRA View Post
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
 
Old 01-03-2011, 04:45 AM   #6
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291Reputation: 1291
Hi Srini,

Glad you got your solution. Enjoy Linux.

Kind regards,

Eric
 
  


Reply


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
logrotate not rotating files with date extension ajayan Linux - Newbie 1 10-25-2010 07:08 PM
[SOLVED] merge files by creation/modification date? andre.fm Linux - Newbie 5 10-04-2010 07:41 PM
copying folder and changing extension of files in it? stratotak Linux - Newbie 18 03-10-2009 02:16 AM
copy folder/files according to modification date bkcreddy17 Programming 14 10-15-2008 08:24 PM
Copying Files having a certain Extension using java MRMadhav Programming 1 06-13-2006 08:30 AM


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

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