LinuxQuestions.org
Register a domain and help support LQ
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 04-16-2009, 03:44 AM   #1
Berris.Oliver
LQ Newbie
 
Registered: Feb 2009
Posts: 16

Rep: Reputation: 0
Question Extracting particular files on a tar from a tape


Let's say that we have files archived / stored in the tape (refers to tapes like LTO and DTL) as shown below, where the first 2 digits before the dash is your camera id, the 2 digits after the dash represents the hour, the next 2 digits for the minutes and the last 2 digits for the seconds:

data1/01-100000.mp3
data1/01-100000.mpg
data1/01-100100.mp3
data1/01-100100.mpg
...
data1/04-105900.mp3
data1/04-105900.mpg

Here's the case of this thread, what if I want to extract a range (say from 10:30 up to 10:55 of camera id 2) that will be coming from a tape in the Tape Archive and by getting it in one pass (or executing the tar command just once)?

Here's the command I'm currently using but this one extracts the archive in the tape until it reaches an end of file and then places it in a directory named multimedia:

tar -C multimedia -xvpf /dev/nst0 data1

So if I use this, I have to remove the files not needed and retain the files with the time range & camera specified. Doing that isn't efficient at all since you use up disk space and waste time. What will be the command for this case? If I get the .mpg file, I should also get the .mp3 file.

Last edited by Berris.Oliver; 04-16-2009 at 03:50 AM.
 
Old 04-16-2009, 03:57 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Have you tried something like

tar -C multimedia -xvpf /dev/nst0 data1/02-103???.mpg data1/02-104???.mpg data1/02-105???.mpg

and just trimmed the ones post 55?

Edit - just noticed there's a mix of mpg and mp3 files, so you'd need to add the mp3's as well
 
Old 04-16-2009, 04:04 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
My wild guess is that you should be able to do something like

Code:
echo $(seq -f "data1/02-10%02.0f00.mp" 30 55)|awk '{for(i=1;i<=NF; i++){printf "%s3 %sg", $i, $i}}'| xargs tar -C multimedia -xvpf /dev/nst0
Completely untested; but the bit from echo to the second pipe
should produce a list of the files you asked for?



Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 12:02 PM
extracting tar.gzip files drmjh Linux - Newbie 6 08-15-2007 03:30 AM
extracting multiple files with tar -xjvf logicalfuzz Linux - Software 3 11-06-2005 02:21 AM
geting problem in extracting tar files p_garg Linux - Enterprise 1 09-29-2005 03:53 PM
extracting tar.bz2.gz files crank Linux - Newbie 5 04-19-2004 12:33 AM


All times are GMT -5. The time now is 09:01 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration