Piping Find and Move Command Output to a file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm executing the following command and the output is not going to the
move.log file. Am I missing something in the command?



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ >> /db_backups/move.log 2>&1 ;






share|improve this question
















  • 2




    mv (without the -v or --verbose option) doesn't usually produce standard output - what are you expecting exactly?
    – steeldriver
    Jan 30 at 15:11










  • The find command, in the way that it is being used here, does nat produce any output.
    – Kusalananda
    Jan 30 at 15:37










  • That did it. Thanks. Was trying to just generate a record of what files were getting moved.
    – Ohly
    Jan 30 at 15:40














up vote
0
down vote

favorite












I'm executing the following command and the output is not going to the
move.log file. Am I missing something in the command?



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ >> /db_backups/move.log 2>&1 ;






share|improve this question
















  • 2




    mv (without the -v or --verbose option) doesn't usually produce standard output - what are you expecting exactly?
    – steeldriver
    Jan 30 at 15:11










  • The find command, in the way that it is being used here, does nat produce any output.
    – Kusalananda
    Jan 30 at 15:37










  • That did it. Thanks. Was trying to just generate a record of what files were getting moved.
    – Ohly
    Jan 30 at 15:40












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm executing the following command and the output is not going to the
move.log file. Am I missing something in the command?



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ >> /db_backups/move.log 2>&1 ;






share|improve this question












I'm executing the following command and the output is not going to the
move.log file. Am I missing something in the command?



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ >> /db_backups/move.log 2>&1 ;








share|improve this question











share|improve this question




share|improve this question










asked Jan 30 at 15:07









Ohly

31




31







  • 2




    mv (without the -v or --verbose option) doesn't usually produce standard output - what are you expecting exactly?
    – steeldriver
    Jan 30 at 15:11










  • The find command, in the way that it is being used here, does nat produce any output.
    – Kusalananda
    Jan 30 at 15:37










  • That did it. Thanks. Was trying to just generate a record of what files were getting moved.
    – Ohly
    Jan 30 at 15:40












  • 2




    mv (without the -v or --verbose option) doesn't usually produce standard output - what are you expecting exactly?
    – steeldriver
    Jan 30 at 15:11










  • The find command, in the way that it is being used here, does nat produce any output.
    – Kusalananda
    Jan 30 at 15:37










  • That did it. Thanks. Was trying to just generate a record of what files were getting moved.
    – Ohly
    Jan 30 at 15:40







2




2




mv (without the -v or --verbose option) doesn't usually produce standard output - what are you expecting exactly?
– steeldriver
Jan 30 at 15:11




mv (without the -v or --verbose option) doesn't usually produce standard output - what are you expecting exactly?
– steeldriver
Jan 30 at 15:11












The find command, in the way that it is being used here, does nat produce any output.
– Kusalananda
Jan 30 at 15:37




The find command, in the way that it is being used here, does nat produce any output.
– Kusalananda
Jan 30 at 15:37












That did it. Thanks. Was trying to just generate a record of what files were getting moved.
– Ohly
Jan 30 at 15:40




That did it. Thanks. Was trying to just generate a record of what files were getting moved.
– Ohly
Jan 30 at 15:40










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










Your find command line:



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ >> /db_backups/move.log 2>&1 ;


is the same as



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ ; >>/db_backups/move.log 2>&1 


The find command, when used in this way, will not produce any output at all and therefore no new data will be written to the move.log file.



If you wanted to store the names of the files that were moved, add -print before the -exec:



find /db_backups/30_plus_days -type f -mtime +90 -print -exec mv /db_backups/90_plus_days/ ; >>/db_backups/move.log 2>&1


or, with nicer line-breaks (only for readability):



find /db_backups/30_plus_days 
-type f -mtime +90 -print
-exec mv /db_backups/90_plus_days/ 2>&1 ;
>>/db_backups/move.log





share|improve this answer






















  • Actually, -print -exec mv ... will print the names of the files before the command tries to move them. But doing it the other way around, -exec mv ... ; -print will only print them after the move has successfully completed (and will not print if it fails)
    – ilkkachu
    Jan 30 at 16:48










  • @ilkkachu But if it fails I'd assume that mv would say something, which in turn would go into the log.
    – Kusalananda
    Jan 30 at 17:44










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f420701%2fpiping-find-and-move-command-output-to-a-file%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










Your find command line:



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ >> /db_backups/move.log 2>&1 ;


is the same as



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ ; >>/db_backups/move.log 2>&1 


The find command, when used in this way, will not produce any output at all and therefore no new data will be written to the move.log file.



If you wanted to store the names of the files that were moved, add -print before the -exec:



find /db_backups/30_plus_days -type f -mtime +90 -print -exec mv /db_backups/90_plus_days/ ; >>/db_backups/move.log 2>&1


or, with nicer line-breaks (only for readability):



find /db_backups/30_plus_days 
-type f -mtime +90 -print
-exec mv /db_backups/90_plus_days/ 2>&1 ;
>>/db_backups/move.log





share|improve this answer






















  • Actually, -print -exec mv ... will print the names of the files before the command tries to move them. But doing it the other way around, -exec mv ... ; -print will only print them after the move has successfully completed (and will not print if it fails)
    – ilkkachu
    Jan 30 at 16:48










  • @ilkkachu But if it fails I'd assume that mv would say something, which in turn would go into the log.
    – Kusalananda
    Jan 30 at 17:44














up vote
1
down vote



accepted










Your find command line:



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ >> /db_backups/move.log 2>&1 ;


is the same as



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ ; >>/db_backups/move.log 2>&1 


The find command, when used in this way, will not produce any output at all and therefore no new data will be written to the move.log file.



If you wanted to store the names of the files that were moved, add -print before the -exec:



find /db_backups/30_plus_days -type f -mtime +90 -print -exec mv /db_backups/90_plus_days/ ; >>/db_backups/move.log 2>&1


or, with nicer line-breaks (only for readability):



find /db_backups/30_plus_days 
-type f -mtime +90 -print
-exec mv /db_backups/90_plus_days/ 2>&1 ;
>>/db_backups/move.log





share|improve this answer






















  • Actually, -print -exec mv ... will print the names of the files before the command tries to move them. But doing it the other way around, -exec mv ... ; -print will only print them after the move has successfully completed (and will not print if it fails)
    – ilkkachu
    Jan 30 at 16:48










  • @ilkkachu But if it fails I'd assume that mv would say something, which in turn would go into the log.
    – Kusalananda
    Jan 30 at 17:44












up vote
1
down vote



accepted







up vote
1
down vote



accepted






Your find command line:



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ >> /db_backups/move.log 2>&1 ;


is the same as



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ ; >>/db_backups/move.log 2>&1 


The find command, when used in this way, will not produce any output at all and therefore no new data will be written to the move.log file.



If you wanted to store the names of the files that were moved, add -print before the -exec:



find /db_backups/30_plus_days -type f -mtime +90 -print -exec mv /db_backups/90_plus_days/ ; >>/db_backups/move.log 2>&1


or, with nicer line-breaks (only for readability):



find /db_backups/30_plus_days 
-type f -mtime +90 -print
-exec mv /db_backups/90_plus_days/ 2>&1 ;
>>/db_backups/move.log





share|improve this answer














Your find command line:



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ >> /db_backups/move.log 2>&1 ;


is the same as



find /db_backups/30_plus_days -type f -mtime +90 -exec mv /db_backups/90_plus_days/ ; >>/db_backups/move.log 2>&1 


The find command, when used in this way, will not produce any output at all and therefore no new data will be written to the move.log file.



If you wanted to store the names of the files that were moved, add -print before the -exec:



find /db_backups/30_plus_days -type f -mtime +90 -print -exec mv /db_backups/90_plus_days/ ; >>/db_backups/move.log 2>&1


or, with nicer line-breaks (only for readability):



find /db_backups/30_plus_days 
-type f -mtime +90 -print
-exec mv /db_backups/90_plus_days/ 2>&1 ;
>>/db_backups/move.log






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 30 at 15:54

























answered Jan 30 at 15:41









Kusalananda

103k13202318




103k13202318











  • Actually, -print -exec mv ... will print the names of the files before the command tries to move them. But doing it the other way around, -exec mv ... ; -print will only print them after the move has successfully completed (and will not print if it fails)
    – ilkkachu
    Jan 30 at 16:48










  • @ilkkachu But if it fails I'd assume that mv would say something, which in turn would go into the log.
    – Kusalananda
    Jan 30 at 17:44
















  • Actually, -print -exec mv ... will print the names of the files before the command tries to move them. But doing it the other way around, -exec mv ... ; -print will only print them after the move has successfully completed (and will not print if it fails)
    – ilkkachu
    Jan 30 at 16:48










  • @ilkkachu But if it fails I'd assume that mv would say something, which in turn would go into the log.
    – Kusalananda
    Jan 30 at 17:44















Actually, -print -exec mv ... will print the names of the files before the command tries to move them. But doing it the other way around, -exec mv ... ; -print will only print them after the move has successfully completed (and will not print if it fails)
– ilkkachu
Jan 30 at 16:48




Actually, -print -exec mv ... will print the names of the files before the command tries to move them. But doing it the other way around, -exec mv ... ; -print will only print them after the move has successfully completed (and will not print if it fails)
– ilkkachu
Jan 30 at 16:48












@ilkkachu But if it fails I'd assume that mv would say something, which in turn would go into the log.
– Kusalananda
Jan 30 at 17:44




@ilkkachu But if it fails I'd assume that mv would say something, which in turn would go into the log.
– Kusalananda
Jan 30 at 17:44












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f420701%2fpiping-find-and-move-command-output-to-a-file%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay