package mainimport ( "os/exec" "fmt")func main(){ cmd := exec.Command("find", "/home/d101270c/cbe", "-name","*.log", ">", "log.txt") fmt.Println(cmd) err := cmd.Run() if err != nil { fmt.Printf("%s\n", err) return }}运行结果:<1067 linux20 [d101270c] :/home/d101270c>uname -aLinux linux20 2.6.16.60-0.21-smp #1 SMP Tue May 6 12:41:02 UTC 2008 x86_64 x86_64 x86_64 GNU/Linux<1068 linux20 [d101270c] :/home/d101270c>tgo&{/usr/bin/find [find /home/d101270c/cbe -name *.log > log.txt] [] <nil> <nil> <nil> [] <nil> <nil> <nil> <nil> false [] [] [] [] <nil>}exit status 1该命令执行失败,不log.txt存在。为什么?
2 回答
- 2 回答
- 0 关注
- 492 浏览
添加回答
举报
0/150
提交
取消