Removing Extra Folders From a TAR


 
Thread Tools Search this Thread
# 1  
Removing Extra Folders From a TAR

I use an extremely simple TAR function for files at work and I have a question about cleaning them up.

My command is TAR -cvf ExampleTarName.tar then the folder I wish to TAR.

When my TAR finishes and I double click it to check it unarchived beautifully (I don't do this with every file, duh) a long folder bath exists before I get to the actual Folder and Files that I want in the TAR. Example:

User/myname/Desktop/To Upload/GraphicName/AfterEffectsFiles

The bolded section ALL I'd like to see TARed in my finished product. How do I make that happen?

Possibly really simple to fix! Thank you in advance!
# 2  
Use the -C option to tell tar to change directory before archiving.
Code:
tar -C User/myname/Desktop/To Upload/ -vcf filename.tar GraphicName/AfterEffectsFiles

# 3  
Awesome, Corona, trying now!

Am I using the right order? Should it be -vcf or -cvf?

---------- Post updated at 02:17 PM ---------- Previous update was at 02:07 PM ----------

Doesn't work.Still get a bunch of extra folders in my finished TAR. And -vcf made the Terminal explode.

I swear I read about a fix about this forever ago, any other idea out there besides change directories?
# 4  
Quote:
Originally Posted by Dogtown24
Awesome, Corona, trying now!

Am I using the right order? Should it be -vcf or -cvf?
The order doesn't matter. Play scrabble if you want. You can also explode them into -v -c -f.
Quote:
Doesn't work.Still get a bunch of extra folders in my finished TAR. And -vcf made the Terminal explode.
Tell me exactly what you typed, word for word, letter for letter, keystroke for keystroke. I don't think -vcf had anything to do with it, you might have accidentally dumped data into the terminal.
# 5  
I'll have to make some text folders since I'm working with corporate sensitive things. I'll respond with screenshots on Monday, when I have more time! Thanks for you help, Corona Smilie
# 6  
I tried what I posted before I did so, and it did work. Change the filenames of course, but "doesn't work" doesn't tell me what you actually did.

I'll make an example for you.

Code:
$ mkdir -p a/b/c/d
$ touch a/b/c/d/e
$ tar -C a/b -vcf filename.tar c/d
c/d/
c/d/e

$ tar -C a/b -vcf filename.tar c/d # See, it's the same
c/d/
c/d/e

$ tar -tf filename.tar # As requested, leading folders a/b are stripped off in the tarball
c/d/
c/d/e

$

 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Science: Mathematics
Difficulty: Hard
L'Hôpital was the mathematician who created the homonymous rule that uses derivatives to evaluate limits with indeterminations.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - Removing extra character when setting variable

I have a data file d0 that looks like this: $cat d0 server1 running -n-cv- 8G 3.1% 1435d 15h server2 running -n---- 8G 39% 660d 22h server3 running -n--v- 8G 2.5% 1173d 6h server4 running -n---- 8G 1.1% 1048d 20h... (2 Replies)
Discussion started by: jake0391S
2 Replies

2. Shell Programming and Scripting

sed removing extra character from end

Hi, Searching through forum I found "sed 's/*$//'" can be used to remove trailing whitespaces and tabs from file. The command works fine but I see minor issue as below. Can you please suggest if I am doing something wrong here. $ cat a.txt upg_prod_test upg_prod_new $ cat a.txt |sed... (11 Replies)
Discussion started by: bhupinder08
11 Replies

3. Shell Programming and Scripting

Removing extra lines from file

I have a file where data looks like this: === <?xml version="1.0" encoding="utf-8"?> <xml xmlns:s='uuid:XYZ' xmlns:dt='uuid:ABC' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'> <s:Schema id='RowsetSchema'> <s:ElementType name='row'... (7 Replies)
Discussion started by: vx04
7 Replies

4. Shell Programming and Scripting

Checking subset and removing extra letters

In each line of file, I wish to check if word1 is a non-connected subset of any of the other words in the line. If yes, keep only the words that ward1 is a subset of. Else, remove the whole line. Also, I want to remove the letters that word1 doesn't match with, except for "_+" Example file:... (2 Replies)
Discussion started by: Viernes
2 Replies

5. Shell Programming and Scripting

Removing extra unwanted spaces

hi, i need to remove the extra spaces in the 2nd field. Sample: abc|bd |bkd123 .. 1space abc|badf |bakdsf123 .. 2space abc|bqe |bakuowe .. 3space Output: abc|bd|bkd123 abc|badf|bakdsf123 abc|bqe|bakuowe i used the following command, (9 Replies)
Discussion started by: anshaa
9 Replies

6. Shell Programming and Scripting

Removing extra unwanted spaces

hi, i need to remove the extra spaces in the filed. Sample: abc~bd ~bkd123 .. 1space abc~badf ~bakdsf123 .. 2space abc~bqed ~bakuowe .. 3space output: abc~bd ~bkd123 .. 1space abc~badf~bakdsf123 .. 2space abc~bqed~bakuowe .. 3space i used the following command, (2 Replies)
Discussion started by: anshaa
2 Replies

7. UNIX for Dummies Questions & Answers

Removing extra new line characters

Hello, I have a text file that looks like: ABC123|some text|some more text|00001 00002 0003 0004 000019|000003|Item I have searched and found an example to remove the extra new line characters using grep and sed, but it (I think) assumes the lines start with a number and the... (5 Replies)
Discussion started by: c56444
5 Replies

8. UNIX for Dummies Questions & Answers

Help with Removing extra characters in Filename

Hi, It's my first time here... anyways, I have a simple problem with these filenames. This is probably too easy for you guys: ABC_20101.2A.2010_01 ABD_20103.2E.2010_04 ABE_20107.2R.2010_08 Expected Output: ABC_20101 ABD_20103 ABE_20107 The only pattern available are the ff: 1) All... (9 Replies)
Discussion started by: Joule
9 Replies

9. Shell Programming and Scripting

removing extra files in dos

Hi, I have same file by name i want to keep only access file and want to delete rest. This is specific to DOS only. Any idea of doing this. I tried so many options but none worked for me. Thanks Namish (11 Replies)
Discussion started by: namishtiwari
11 Replies

10. UNIX for Dummies Questions & Answers

removing linux/extra partition??

ok, well i never could get my internet connection setup in linux so now it is just wasting space on my system... so, how do i get rid of it and the extra partition made during install?? (1 Reply)
Discussion started by: justchillin
1 Replies

Featured Tech Videos