LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-23-2018, 02:57 AM   #1
ramalakshmi
LQ Newbie
 
Registered: Jan 2018
Posts: 1

Rep: Reputation: Disabled
How to extract only contain .tar files


Let me explain clearly:
Suppose i created one file called lost with .tar = lost.tar in /root directory
Files (hai, hello) two files are extracted in lost.tar
Now i want un extract this lost.tar and seperate those files as usual
What are command should use to extract only .tar command???

Last edited by ramalakshmi; 03-23-2018 at 02:58 AM.
 
Old 03-23-2018, 03:04 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,899

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
how did you create that file exactly? (which commands were used)?
I think you can use tar too to get your files, see man tar (especially the flag -x)
 
1 members found this post helpful.
Old 03-23-2018, 03:51 AM   #3
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,500

Rep: Reputation: Disabled
If this is homework, you should say so(?), that's not to say you won't get help, but we usually prefer to guide you rather than just give the answer.
(man tar)

Code:
tar -xvf file.tar
 
1 members found this post helpful.
Old 03-23-2018, 09:38 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by ramalakshmi View Post
Let me explain clearly:
Suppose i created one file called lost with .tar = lost.tar in /root directory
Files (hai, hello) two files are extracted in lost.tar
Now i want un extract this lost.tar and seperate those files as usual
What are command should use to extract only .tar command???
Firstly, fatmac and pan64 are correct.

To extract files from a tar file you use the -x option.

My simple two tar "view" and "extract" argument lists are: -tvf and -xvf.

The -tvf will list the files in the tar file for you.

The -xvf will extract the files the tar file for you.

Note that tar means (t)ape (ar)chive.

This goes back to the days when people backed up data onto large reel to reel tapes.

https://www.zdnet.com/pictures/tale-...0-years-at-ibm

And all that tar normally does is to concatenate files together in an organized fashion so that it knows how to extract the files in their original form.

It can optionally zip the archive file, and these days you do not need any arguments to do this, just when you create you use a filename with the zip extension, such as .xz or .bz2 or so forth.

A final point is that when you say the two files are extracted in lost.tar; that would be a technically incorrect thing to say. They are archived in that file and to get them out you would perform an extract operation.

If you're experimenting with tar, then a suggestion is to use two one line text files, put those into a tar archive, then cat the tar file to see what it shows. This should make more clear my point that it is really a concatenation of those files, with additional information used by the tar program.
 
Old 03-23-2018, 10:56 AM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,804

Rep: Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203
It's always a good idea to first list the contents of the tarfile
Code:
tar -tf lost.tar
Then you see the pathnames of the files, and you can prevent an accidental extraction to the wrong location or even overwriting an existing file.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
wants to extract the tar.gz files rajini23 Linux - Desktop 8 02-09-2012 11:32 AM
[SOLVED] Extract from `tar` archive as ordered in --files-from zx_ Linux - Newbie 6 02-04-2012 09:08 AM
Extract .tar.bz2 files cahardin76 Linux - Newbie 3 11-13-2010 10:35 PM
How can I extract only *.c files from a tar.gz? [KIA]aze Linux - Newbie 7 06-06-2007 04:39 AM
How to extract tar.bz2 files? akihandyman Linux - Newbie 3 12-21-2003 03:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration