I am new to linux and I am trying the following:
I have directory data. In this directory there are x files that end with *.tgz. I want to unpack each, and store the output in a new folder. So as an example. I start with:
ls data
folder_a.tgz folder_b.tgz folder_c.tgz
I want want to end up with:
ls /data/test/
folder_a folder_b folder_c
I have tried the following:
ls *.tgz | xargs -n1 tar zxvf -C /data/test/
Which gives the error:
-C cannot open: no such file or directory
I do not understand why this does not work, since these both work as expected:
tar zxvf folder_a.tgz -C /data/test/
ls *.tgz | xargs -n1 tar zxvf
But combining these does not work. Can anyone help me to achieve the goal, and maybe explain why my solution does not work?