On 2004-01-13 13:59:10 +0000 Barry Samuels bsamuels@beenthere-donethat.org.uk wrote:
I have a /var/www directory which is a local copy of my web site. I want to copy only the .html files together with any sub-directories that contain .html files (retaining the directory structure), together with their files, into another directory.
For rc: cd /var/www && tar cvf - --files-from <{find . -name '*.html'} | tar xfC - /new/directory
I think bash is the same, but uses () instead of {}
What's going on there? Well, the cd should be obvious. If that succeeds (&&), run tar to Create Verbosely a File (cvf) and that file goes to standard output (-). Tar should read filenames from a file (--files-from) which is actually the output of that find command (that's what the <{...} does, turning command output into a file (really a type of pipe)). Then we send that (|) to another tar command that eXtracts a File (xf) from standard input (-), Changing directory (C) to /new/directory before writing files.
It's like a foreign language sometimes...