The variadic args worked perfectly. Thanks. I did not use the archive/tar and compress/gzip approach because that wold be a lot more complicated than just executing a tar command. Those packages are oriented towards reading/writing the contents of archive/compressed files into the program rather than just extracting a file from a compressed archive.
On Wednesday, April 20, 2022 at 10:28:06 AM UTC-6 wagner riffel wrote: > On Wed Apr 20, 2022 at 6:16 PM CEST, Dean Schulze wrote: > > I need to execute this tar command > > > > *tar xzf dir1/dir2/somefile.tgz --directory=dir1/dir2/* > > > > Did you considered using the packages "archive/tar" and > "compress/gzip" to achive this? > > > *argStr := "xzf dir1/dir2/somefile.tgz --directory=dir1/dir2/"output, err > > := exec.Command("tar", argStr).Output()* > > > > exec.Command arguments are variadic, each argument is one argv, thus I > think you meant exec.Command("tar", "xzf", "dir1/dir2/somefile.tgz", > "--directory=dir1/dir2/") > > -w > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2556c040-94e3-487e-b5b1-ecbe75bb7d47n%40googlegroups.com.