LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   want to 'tar' a folder without some contents of folder (http://www.linuxquestions.org/questions/linux-newbie-8/want-to-tar-a-folder-without-some-contents-of-folder-591355/)

shipon_97 10-12-2007 01:51 PM

want to 'tar' a folder without some contents of folder
 
Friends ,

Suppose I have a folder "test" . In test folder I have 5 files , Like "file1" "file2" "file3" "file4" and "file5" .

Now I want to compress (tar) the "test" folder without the file "file4" and "file5" .

Like follwing :

tar -cvf test.tar test //
it should not contain the 'file4' and 'file5' .

Is it possible to do ? If yes then plz help me ....

matthewg42 10-12-2007 01:53 PM

You should search for "exclude" in the tar manual page.

b0uncer 10-12-2007 01:58 PM

Code:

man tar
then type '/' (shift+7 if you've got a keyboard like mine) followed by 'exclude' without spaces, and hit ENTER. So,
Code:

/exclude
If you found what you wanted, read further -- if not, write again '/' (no need to retype the same search string unless you change it) and hit ENTER to head for the next hit. It works backwards the same way, except the "search letter" is '?', not '/'.

matthewg42 10-12-2007 02:01 PM

If you use KDE you can also view manual pages in konqueror by entering
Code:

man:pagename
in the location bar.

shipon_97 10-13-2007 03:44 AM

exclude a folder using tar command
 
Thx all for reply ...

I can do it in the case of "file" format . But If I want to tar excluding a folder
Like /var or /myfolder Like following way :

tar -cvf test.tar --exclude /myfolder

Then it does not working .

Plz help how can I exclude a folder using tar ?

unSpawn 10-13-2007 04:21 AM

You left out the files it *should* tar up?


All times are GMT -5. The time now is 09:04 PM.