when an using exec.Cmd to fock an subprocess,with redirection like cat xxx > /tmp/xxxx ,it will always fail.
cmd:=exec.Command("cat","./aaa",">","/tmp/aaa")
cmd.Start()
err:=cmd.Wait()
if err!=nil {
t.Errorf("exit error %s", err)
}
wheather /tmp/aaa is exist or not, error is always "exit status 1" .
file aaa is always exist.
when i set cmd's Stderr to bytes.Buffer ,and i see detail error:"cat: >d: no such file or directory". so i think go maybe treat '>' as a file name.
so how should i do when i want to use redirection symbol in command