How do I extract files without folder structure using tar

后端 未结 5 1441
无人共我
无人共我 2021-01-30 12:11

I have a tar.gz-file with the following structure:

folder1/img.gif
folder2/img2.gif
folder3/img3.gif

I want to extract the image files without

5条回答
  •  一向
    一向 (楼主)
    2021-01-30 13:06

    Check the tar version e.g.

    $ tar --version
    

    If version is >= than tar-1.14.90 use --strip-components

    tar xvzf web.dirs.tar.gz -C /srv/www --strip-components 2
    

    else use --strip-path

    tar xvzf web.dirs.tar.gz -C /srv/www --strip-path 2
    

提交回复
热议问题