![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to write bash script to explode multiple zip files | siegfried | Shell Programming and Scripting | 3 | 02-07-2009 09:54 PM |
| Executing Multiple .SQL Files from Single Shell Script file | anushilrai | Shell Programming and Scripting | 3 | 04-07-2008 11:09 AM |
| How to execute multiple(batch) oracle script in unix mechine | ravi gongati | Shell Programming and Scripting | 2 | 03-21-2008 07:37 AM |
| Converting Shell script to Dos batch files | darwinkna | Shell Programming and Scripting | 1 | 05-12-2006 12:01 PM |
| Schedule a Batch file to delete files at particular intervals | Indom | Windows & DOS: Issues & Discussions | 6 | 02-04-2004 12:57 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
so i have hundreds of files named history.20071112.tar
(history.YYYYMMDD.tar) and im looking to extract one file out of each archive called status_YYYYMMDDHH:MM.lis here is what i have so far: for FILE in `cat dirlist` do tar xvf $FILE ./status_* done dirlist is a text containg the full path to the tar files i want to extract the single file from: /export/home/psxfer/history/archive/history.20070101.tar /export/home/psxfer/history/archive/history.20070102.tar /export/home/psxfer/history/archive/history.20070103.tar /export/home/psxfer/history/archive/history.20070104.tar /export/home/psxfer/history/archive/history.20070105.tar etc... the problem is that it doesnt look like tar is liking the wildcard and needs the exact file name of the single file to extract so it's not working. anyone have any ideas? or would i need to run tar -tf history.YYYYMMDD.tar for each file to get the exact filename for the .lis file? thanks in advance!! i forgot to mention that this is solaris 8 if that makes a difference. Last edited by kuliksco; 11-13-2007 at 01:11 AM.. |
|
||||
|
Well, this *should* work. There are caveats, tho. First, the pattern should be quoted, since it will be expanded by the shell if it matches any files in the current directory. Second, the filename must match precisely, path and all. Are you sure the file is stored in the archive as "./foo.bar" ?
|
|
||||
|
Quote:
tar -tf /export/home/psxfer/history/archive/history.20070101.tar ./status2_2007010107:00.lis.gz ./status3_2007010107:00.lis.gz ./status_2007010107:00.lis.gz ./RSCAR084_482134.pdf.gz ./rscem001_482111.lis.gz ./rscem002_482114.lis.gz ./rscem006_482110.lis.gz ./rscem006_482113.lis.gz ./rscbi068_482140.lis.gz ./RSCPT002_482144.pdf.gz ./rscpt003_482143.txt.gz ./rscpt004_476773.txt.gz |
|
||||
|
Curious, I didn't have a problem extracting from tar via wildcards on OSX (it was the nearest Unix machine). I guess you'll need to extract the name first, as you already suggested, although it means scanning each archive twice (arrrrrg).
|
|
||||
|
Quote:
for FILE in `cat $1` do LIS=`tar -tf $FILE | grep ./status_` tar -xvf $FILE $LIS done easier than i thought. not sure if there was a better way other than using grep. thanks again for the help. Last edited by kuliksco; 11-13-2007 at 11:37 AM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|