user3713876
user3713876

Reputation: 41

issue with the tar file to excude some files and rar only required files in the folder with same structure

hi i have a requirement like the following

| |------bar/ |--file.pl |---FILE1.FILE2.FILE3.TXT |---FILE4.FILE5.FILE6.TXT | |---subdir1/ | |---file1_file2.log | |---file2_file1.log | |---subdir2/ |---image1_image2.log |---image2_image1.log

i am using the following command.

tar cvzf bar/ x.tar

and the output i am getting is as follows

| |------bar/ |--file.pl |---FILE1.FILE2.FILE3.TXT |---FILE4.FILE5.FILE6.TXT | |---subdir1/ | |---file1_file2.log | |---file2_file1.log | |---subdir2/ |---image1_image2.log |---image2_image1.log

but i want the output like the following.i want to exclude .pl and i want only x.x.x.TXT and .LOG to be tar.

| |------bar/ | |---FILE1.FILE2.FILE3.TXT |---FILE4.FILE5.FILE6.TXT | |---subdir1/ | |---file1_file2.log | |---file2_file1.log | |---subdir2/ |---image1_image2.log |---image2_image1.log

thanks in advance.

Upvotes: 0

Views: 67

Answers (2)

Sanket Parmar
Sanket Parmar

Reputation: 1577

$ tar cvzf x.tar bar/ --exclude=*.pl

From man page:

--exclude=PATTERN
   exclude files, given as a PATTERN

Upvotes: 2

neo
neo

Reputation: 1009

Try this.

find ./someDir -name "*.log" -o -name "*.TXT" | tar -cf my_archive -T -

Upvotes: 0

Related Questions