Monday, November 15, 2010

tar into a pipe and then out of the pipe for copying files

Sometimes you want to copy a directory from one location to another and in order to preserve all permissions, etc, you can easily tar the files into a pipe and then out of the pipe:

cd fromdir; tar cf - .| (cd todir; tar xfBp -)

Drop a 'v' (without the quote marks) into the second tar command and you will get a file listing of all the files it extracts from the pipe.