I sometimes have to make a tar file excluding certain directories or files, and it's subtly different in linux from solaris.
For example, we want to create a tar file from a directory called ./mydir, name the output file mydir.tar(.gz) and we put into ./mydir/Exclude a list of files to be excluded from the resulting tar file.
Solaris version:
tar cvfX mydir.tar ./mydir/Exclude ./mydir
will create a tar file called mydir.tar containing all subdirectories of ./mydir and at extraction time it will create a directory ./mydir as well
Linux version:
tar -cvf mydir.tar --exclude=Exclude ./mydir
or, if you directly want a gzip file:
tar -zcvf mydir.tar --exclude=Exclude ./mydir
where the contents of the exclude file ./mydir/Exclude are in both cases identical, and for example like (it's assumend to be the relative path to ./mydir):
Exclude
foo
bar
So that's pretty much it. It's very easy, but I always get confused about it, and the differences existing between linux and the Solaris only make all worse to remember.
No comments:
Post a Comment