home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 20.8 Telling tar Which Files to Exclude or Include Chapter 20
Backing Up Files
Next: 20.10 Avoid Absolute Paths with tar
 

20.9 When a Program Doesn't Understand Wildcards

When extracting files from a tar archive, it's handy to be able to use wildcards. You have to protect them ( 8.14 ) from the shell, so that they are passed directly to tar .

However, in general tar don't understand wildcards. There's a terribly ugly hack that you can use to select the files you want anyway. Try a command like this:



`...`
 

% 

tar xvf /dev/rst0 `tar tf /dev/rst0 | egrep  'lib/(foo|bar)'`

What you're doing here is using tar twice. tar t will print the names of all the files on the tape. The pattern supplied to egrep ( 27.5 ) selects the pathnames containg lib/foo or lib/bar , and the resulting filenames are passed to the first tar command, which actually extracts the files from the archive.

- TOR


Previous: 20.8 Telling tar Which Files to Exclude or Include UNIX Power Tools Next: 20.10 Avoid Absolute Paths with tar
20.8 Telling tar Which Files to Exclude or Include Book Index 20.10 Avoid Absolute Paths with tar

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System