Piping Find and Move Command Output to a file
Clash 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 ;
linux find mv exec
add a comment |Â
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 ;
linux find mv exec
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
Thefind
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
add a comment |Â
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 ;
linux find mv exec
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 ;
linux find mv exec
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
Thefind
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
add a comment |Â
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
Thefind
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
add a comment |Â
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
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 thatmv
would say something, which in turn would go into the log.
â Kusalananda
Jan 30 at 17:44
add a comment |Â
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
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 thatmv
would say something, which in turn would go into the log.
â Kusalananda
Jan 30 at 17:44
add a comment |Â
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
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 thatmv
would say something, which in turn would go into the log.
â Kusalananda
Jan 30 at 17:44
add a comment |Â
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
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
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 thatmv
would say something, which in turn would go into the log.
â Kusalananda
Jan 30 at 17:44
add a comment |Â
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 thatmv
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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