You can't cd
in xargs
because xargs is not a shell... or something. You have to invoke bash.
ls -1 directory | xargs -n1 -I{} bash -c 'cd {}; echo foobar'
Use -t
if you want to see the resulting command executed.
You can't cd
in xargs
because xargs is not a shell... or something. You have to invoke bash.
ls -1 directory | xargs -n1 -I{} bash -c 'cd {}; echo foobar'
Use -t
if you want to see the resulting command executed.