echo ls -l -a / | xargs sh -c
How to make above command work?
it only list current directory
seems only ls is passed to xargs
echo '"ls -l -a /"' | xargs sh -c
would work though, but the input I got has no ""
Source: http://www.unixmantra.com/2013/12/xargs-all-in-one-tutorial-guide.html
as mentioned by @darklion, -I denoted the argument list marker and -c denotes bash command to run on every input line to xargs.
Simply print the input to xargs:
ls -d */ | xargs echo
#One at a time
ls -d */ | xargs -n1 echo
More operations on every input:
ls -d */ | xargs -n1 -I {} /bin/bash -c ' echo {}; ls -l {}; '
You can replace {} with customized string as:
ls -d */ | xargs -n1 -I file /bin/bash -c ' echo file; ls -l file; '
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With