Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

this command finds me files which I want to move to old folder

find /home/ -maxdepth 1 -type f -mtime +1

now how I cann result of this command to move command

mv (previous files) /old
share|improve this question

migrated from stackoverflow.com Mar 4 '13 at 15:56

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

up vote 1 down vote accepted

You can also use xargs.

find /home/ -maxdepth 1 -type f -mtime +1 | xargs mv -I '{}' mv {} /old/
share|improve this answer
1  
You meant xargs -I '{}' mv {} /old/ –  anishsane Mar 4 '13 at 13:42
    
Wow, I thought it would be enough with what I wrote. Thank you, now I see it was not complete and yours is working, @anishsane. –  fedorqui Mar 4 '13 at 13:44
    
thx anishame ur fix works perfectly –  hudi Mar 4 '13 at 13:44
    
We should give this +something to @anishane! : D –  fedorqui Mar 4 '13 at 13:46
    
I add +1 to your commend –  hudi Mar 4 '13 at 13:47
show 2 more comments
find /home/ -maxdepth 1 -type f -mtime +1 -exec mv -- '{}' /old/ +
share|improve this answer
    
ur command gives me error: find: missing argument to `-exec' –  hudi Mar 4 '13 at 13:40
    
What does find --version say? And did you include the +? –  melpomene Mar 4 '13 at 13:42
    
yes I include+ find (GNU findutils) 4.4.2 Copyright (C) 2007 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <gnu.org/licenses/gpl.html>; This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Eric B. Decker, James Youngman, and Kevin Dalley. Built using GNU gnulib version e5573b1bad88bfabcda181b9e0125fb0c52b7d3b Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS() CBO(level=0) –  hudi Mar 4 '13 at 13:43
    
+1 to this answer from me. -exec is the option provided for this exact reason. –  anishsane Mar 4 '13 at 13:53
    
yea but this example doesnt work for me –  hudi Mar 4 '13 at 14:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.