I am using go to run a shell script using exec.command like below and I want to take an input argument using command line say i
, and my output should be based on i
, how would I do that?
i := os.Args[1:2]
out, err := exec.Command("bash", "-c", "tail -n 1 /var/log/apache2/access.log | awk '{print $i/1024}' >> mem_usage.csv").Output()
if err != nil {
fmt.Println(err.Error())
return
}
How could I use that i in the shell script?
Without i
it works fine i.e if I put $1
or $2
it works fine but I want user to give me the position of i
and then calculate accordingly.