bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: combine xargs with EOF


From: DJ Mills
Subject: Re: combine xargs with EOF
Date: Wed, 17 Oct 2012 13:20:22 -0400

On Wed, Oct 17, 2012 at 12:49 PM,  <giuseppe.amatulli@gmail.com> wrote:
> Hi
> i'm using often xargs to run process in parallel
>
> ls *.txt | xargs -n 1 -P 10 bash myscript.sh
>
> where myscript.sh is (for examples of course is longer):
> echo $1
>
> i would like to perform the same operation using the EOF syntax and import 
> the arguments inside the eof
>
> I tried
>
> ls *.txt | xargs -n 1 -P 10 <<
> echo $1
> EOF
>
> also with the option -E and -e but did not work
>
> any ideas?
> thanks Giuseppe
>

xargs can't read both from a pipe and a here document, they're both on stdin.

Also, don't parse ls. http://mywiki.wooledge.org/ParsingLs

But I'm not entirely sure what you're trying to do here... Can you
explain the whole goal, in plain language, without using code?

Also, make sure you quote your expansions. "$1", never $1. See
http://mywiki.wooledge.org/Arguments.

The other issue is that since <<EOF is unquoted, $1 will be expanded
before the here document is passed to xargs. If there are no
arguments, it will simply get 'echo'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]