Extract a specific folder to specific directory from a tar.gz

前端 未结 2 1376
借酒劲吻你
借酒劲吻你 2021-02-08 13:22

I have searched and found how to the two portions of what I want but nothing that would allow you to do it in whole....

What I would like to do is extract a specific fol

2条回答
  •  伪装坚强ぢ
    2021-02-08 14:19

    Ok I figured it out!

    Basically I can just use the strip command to remove the x number of leading directories. In this case, my command would look like this:

    tar -xzf backup.tar.gz --strip-components=3 -C a/b/m

    That removed the first three path directories from my archive (backup.tar.gz : a/b/c/d) before extracting it to the desctination directory.

    Now it looks like this: a/b/m+d

提交回复
热议问题