7

Why does export fail when used as the last step in a command pipeline?

echo FOO=bar | xargs export
# => xargs: export: No such file or directory

I can rewrite it this way to accomplish what I want:

export `echo FOO=bar`

But why can't I use export in the first way?

pje
  • 21,801
  • 10
  • 54
  • 70
  • 1
    To answer the followup question ("how can I get `xargs` to work with functions?"): http://stackoverflow.com/q/11003418/1004889 – pje May 27 '14 at 18:01
  • Note the following will work `export "$(cmd1 | cmd2 | cmd3)"` – Peter Berg Sep 19 '19 at 20:47

1 Answers1

7

export is a shell builtin and xargs expects an actual binary.

hd1
  • 33,938
  • 5
  • 80
  • 91