I expect the commandls -d doc/* | grep -P <some_pattern> | xargs bash -ic echoto do the same as:ls -d doc/* | grep -P <some_pattern> | xargs echothat is, to give me the files matched by ls -d doc/* | grep -P <some_pattern>, only separated by spaces instead of newlines.But I get only a newline as output instead.Why is this? How can I fix the first command to do what I want?By the way, Im realling using zsh instead of bash, but neither will work.I actually need this to print a bunch of files whose file names are matched by the pattern specified by grep and should be printed using an .zshrc-aliased command.
Why is `xargs bash -ic echo` not the same thing as `xargs echo` or `xargs`?
bash;zsh;xargs
from the bash manpage   -c string If the -c option is present,  then  commands  are  read  from             string.   If  there  are arguments after the string, they are             assigned to the positional parameters, starting with $0.so... $ echo a b c d e f g | xargs bash -ic echo $ echo a b c d e f g | xargs bash -ic 'echo $0 $@' a b c d e f g