I have the following command:
find . -type d -mtime 0 -exec mv {} /path/to/target-dir \;
This will move the directory founded to another directory. How can I use xargs instead of exec to do the same thing.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’ve got GNU
mv(andfindandxargs), you can use the-toption tomv(and-print0forfindand-0forxargs):Note that modern versions of
find(compatible with POSIX 2008) support+in place of;and behave roughly the same asxargswithout usingxargs:This makes
findgroup convenient numbers of file (directory) names into a single invocation of the program. You don’t have the level of control over the numbers of arguments passed tomvthatxargsprovides, but you seldom actually need that anyway. This still hinges on the-toption to GNUmv.