Pages

Monday, February 27, 2023

Extracting single directory from tar.gz archive to a specific destination directory

archive-1.05.tar.gz contains the following:

arhive-1.05/config
arhive-1.05/docs
arhive-1.05/lib
arhive-1.05/src

We want to unarchive only contents of the "archive-1.05/lib/" to a specific destination (/home/user/lib)

$ tar -xvzf archive-1.05.tar.gz  -C /home/user/lib --strip-components=1 --no-anchored lib

If we do not specify --no-anchored flag then --strip-components will not work.

No comments: