如何使用Go执行“ cat 7zSD.sfxconfig.txt xxxx.7z> setup.exe” [重复]

In the Linux command line, it's possible to execute:

cat 7zSD.sfx config.txt xxxx.7z > setup.exe

However, trying the same using Go, fails. I tried:

exec.Command("cat 7zSD.sfx config.txt xxxx.7z > setup.exe")

and I get "executable file not found in $PATH."

How can I execute the same command-line using Go?

</div>

You appear to be expecting that exec.Command behave like your interactive shell behaves. It does not work that way. As explained in the exec documentation:

Unlike the "system" library call from C and other languages, the os/exec package intentionally does not invoke the system shell and does not expand any glob patterns or handle other expansions, pipelines, or redirections typically done by shells.