LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-30-2008, 05:48 AM   #1
melikai
Member
 
Registered: Aug 2006
Distribution: Suse 10.1
Posts: 37

Rep: Reputation: 15
cat | tar | mv: Back up question


I made a backup of my /~ drive. Unfortunatly I didn't realize the option of -P when I did it.
I have 10 .tar.gz file. I can 'cat' the files then '|' to gunzip fine. How ever is there any way I can move that to the 'mv' or 'cp' to move in the directory I want it off my usb drive?
Any help would appreciated
Thanks in Advance
 
Old 03-30-2008, 06:24 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You can use the -C option to run the command in the target base directory, or cd to that directory first. Include the full path to the tar files in the cat command.

If a file was backed up like 'home/<username>/file' then you can use something like:
cat /mnt/usbdrive/backupfile.tar.0* | gunzip | tar -C / -

The tar info file shows another example where the tar command that does the untarring is done in a subshell.

From the info manual:
Code:
   For example, here is how you might copy a directory's contents from
one disk to another, while preserving the dates, modes, owners and
link-structure of all the files therein.  In this case, the transfer
medium is a "pipe", which is one a Unix redirection mechanism:

     $ (cd sourcedir; tar -cf - .) | (cd targetdir; tar -xf -)

You can avoid subshells by using `-C' option:

     $ tar -C sourcedir -cf - . | tar -C targetdir -xf -
In your case, you are just unarchiving.

Looking at some of the contents of the archive will help determine where the current working directory should be.

Last edited by jschiwal; 03-30-2008 at 06:26 AM.
 
Old 03-30-2008, 06:41 AM   #3
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Try --strip-components=1 and unpack it in some accessible to you directory. Repack it with better options..
 
Old 04-01-2008, 06:50 AM   #4
melikai
Member
 
Registered: Aug 2006
Distribution: Suse 10.1
Posts: 37

Original Poster
Rep: Reputation: 15
cann yo infrom me about how the '-', '-C', '.' work? what is a good websit to get the low-down on wht its about. When I go thru the man pages i don't any of the symbols or how to use them
 
Old 04-01-2008, 07:21 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The -C option changes the directory that the tar command works in. Many commands (not all) understand a dash argument to mean to take the input from stdin instead of a file. This allows you to use a pipe between commands when the command normally reads from a 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
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 11:02 AM
remote back up wiht GNU tar vlsi Linux - General 5 02-21-2008 06:40 PM
Can I back up hidden files using tar? opto Linux - Newbie 6 11-05-2006 09:35 AM
taking tar back up of only the directory structure procfs Linux - Newbie 3 09-04-2006 07:54 PM
Question About Cat And Grep George2 Linux - Software 10 03-09-2006 03:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:29 AM.

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