I'm trying to run the following command from go.
sed -i 's|/home/output||g' /tmp/results.json
Which blats out /home/output from the file /tmp/result.json.
If I run this from a terminal it works perfectly. However, I can't figure out why it's not liking being run from go exec.
Here is my code.
package main
import (
"fmt"
"log"
"os"
"os/exec"
)
func main() {
cmd := exec.Command("sed", "-i", "'s|/octane/data||g'", "./results.json")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Start(); err != nil {
log.Fatal(err)
}
if err := cmd.Wait(); err != nil {
log.Fatal(err)
}
}
The specific error is:
sed: -e expression #1, char 1: unknown command: `''
2018/03/07 11:48:01 exit status 1
What is causing this unexpected behavior?