Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how use tar and extract everything except certain files? [closed]

Tags:

linux

bash

tar

I want to extract website.tgz but I don't want these to "come out":

app/config.ini
log/

How do I do this?

Or/also how do I overwrite everything except the above?

like image 600
trafalgar Avatar asked Aug 08 '13 11:08

trafalgar


People also ask

How do I extract only certain files from a tar?

Now, if you want a single file or folder from the “tar” file, you need to use the name of the “tar” file and the path to a single file in it. So, we have used the “tar” command with the “-xvf” option, the name of the “tar” file, and the path of a file to be extracted from it as below.

How do I tar exclude a folder?

You can exclude directories with --exclude for tar. To clarify, you can use full path for --exclude. Beware that --exclude=dir/ignore_this_dir will match in any subtree as well! You'll end up missing files you didn't expect to be excluded.

How does tar -- exclude work?

The ' --exclude= pattern ' option prevents any file or member whose name matches the shell wildcard ( pattern ) from being operated on. For example, to create an archive with all the contents of the directory 'src' except for files whose names end in '.o', use the command ' tar -cf src. tar --exclude='*.o' src '.


1 Answers

Try using the following command

tar -xvzf /path/to/tarfile --exclude='file dont want to extract'
like image 97
Tarun Avatar answered Sep 22 '22 03:09

Tarun