1827841 Members
1842 Online
109969 Solutions
New Discussion

Re: rcp files

 
Arnold Frazer
New Member

rcp files

Hi there I am trying to rcp the last modified file with the .dat extension to another server. I have written this but it is sending all files across. Can someone help, please?

find /tmp/ -name "*.dat" -mtime +1 -exec rcp {} 10.1.10.30:/disk3/sx3/RIFACE/ \;

3 REPLIES 3
Ivan Ferreira
Honored Contributor

Re: rcp files

The find -mtime +1 will find all files with a modification date > one day. That is not what you need.

You should use something like this:

rcp `ls -latr |tail -1 | awk '{print $9}'` 10.1.10.30:/disk3/sx3/RIFACE/

Check that the quotation mark is inverted. If you can't find the quotation mark, use:

rcp $(ls -latr |tail -1 | awk '{print $9}') 10.1.10.30:/disk3/sx3/RIFACE/

This is called shell nesting or shell substitution.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Joris Denayer
Respected Contributor

Re: rcp files

Arnold

It should be
-mtime 1 or mtime -1
instead of
-mtime +1

Joris
To err is human, but to really faul things up requires a computer
Muthukumar_5
Honored Contributor

Re: rcp files

Use this,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=995165

to get recent updated file.

--
Muthu
Easy to suggest when don't know about the problem!