I have the following snippet that is not working. Compiles but does not do what it is supposed to. Executing the same command on bash works. Why?
hash:="4ab32de"
cmd = "sed -i -e 's/clt_[0-9a-z]*/clt_"+hash+"/g' /tmp/test.env"
parts = strings.Fields(cmd)
for _, part :=range parts {
fmt.Printf("
%s",part)
}
head = parts[0]
out, err = exec.Command(head,parts[1:]...).Output()
fmt.Printf("
new cmd is %s
",cmd)
fmt.Printf("out:%s",string(out))
The output of parts is perfect, like this
sed
-i
-e
's/clt_[0-9a-z]*/clt_4ab32de/g'
/tmp/test.env