I think this is gonna close to work
find /mydirectory -name '*' | xargs echo abc >
But I got:
find: paths must precede expression: b
Need a little help 🙂
thanks
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.
Try this
Or if you want to do it in bulk:
If you need explanations, ask.
This page is a good guide on how to use find.
In both commands, the
_and{}are passed as arguments to theshcommand. Because $0 isn’t fully reliable to use (see the linked page), a dummy variable_is passed to it.Find puts its matches in
{}, which is expanded. So if the command matches a filea, then{}is expanded toain the first command.In the first command, the command you are passing to exec is terminated with
;, but;is special to the shell, so you escape it.The second command runs as a bulk operation, so if find matches
a,b, andc(etc.), the{}is expanded to all three and passed in.Thus, you need a
for fin the second command, which defaults tofor f in $@, which will be youra,b, andc(and this can be tested by doing ${1}, ${2}, ${3}…).