Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 04-16-2009, 03:44 AM   #1
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:


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
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
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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

echo $(seq -f "data1/" 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?



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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:30 PM.

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