Skip to main content
The 2024 Developer Survey results are live! See the results
8 events
when toggle format what by license comment
Feb 7 at 14:53 comment added Niels Bom env solves the problem of not overwriting the environment variable in the current shell. But OP wants to run ? cmd1 args | cmd2 and have cmd2 be able to read any environment variables set at ? which env does not solve. And @gniourf_gniourf is right: env FOO=FUBAR bash -c 'cmd1 args | cmd2' is functionally similar to FOO=FUBAR bash -c 'cmd1 args | cmd2'.
Jan 9 at 7:24 history edited Pang CC BY-SA 4.0
Remove duplicated word.
Nov 30, 2023 at 6:01 comment added gniourf_gniourf Does this even answer the question? is this answer even correct with its useless use of env?
Jun 6, 2023 at 13:50 comment added cambunctious Using env to set vars for a command is kinda pointless if you are in a shell since you can remove env from the command and it will accomplish the same thing.
Jan 18, 2023 at 12:47 comment added Andrei Bastos I tested it and it works for me, thanks!
Jan 30, 2022 at 18:25 comment added bradw2k This is the exactly correct answer, the entire purpose of env is to solve the stated question.
Jun 26, 2019 at 4:27 history edited benjimin CC BY-SA 4.0
added 341 characters in body
Jun 26, 2019 at 4:19 history answered benjimin CC BY-SA 4.0