Bash team with backticks inside xargs

  echo $TMPLIST | xargs -I{} -n 1 -P $MAXJOBS curl -o {}_$DATESTRING.dump `get-temp-url --location {}`

$ TMPLIST has a list of locations that I want to process. I am trying to run something like the above, but the brackets inside the backticks are not expanding. What am I doing wrong?

+4
source share
1 answer

In this team ...

echo $TMPLIST | 
xargs -I{} -n 1 -P $MAXJOBS curl -o {}_$DATESTRING.dump \
  `get-temp-url --location {}`

... the outputs are interpreted by the shell; they are never visible xargs. You can do something like this:

echo $TMPLIST | 
xargs -I{} -n 1 -P $MAXJOBS \
  sh -c 'curl -o {}_$DATESTRING.dump `get-temp-url --location {}`'

Note that for this, there DATESTRINGmust be an environment variable, not a shell variable (for example, you need to export DATESTRING).

+3
source

All Articles