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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
04-16-2009, 03:44 AM
|
#1
|
LQ Newbie
Registered: Feb 2009
Posts: 16
Rep:
|
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.
|
|
|
04-16-2009, 03:57 AM
|
#2
|
LQ Guru
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678
Rep: 
|
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
|
|
|
04-16-2009, 04:04 AM
|
#3
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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
|
|
|
All times are GMT -5. The time now is 06:21 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|