Linux – exclude directory with tar command

excludelinuxtar

T would like to use the tar command in Linux to back up some files, but i would like to exclude a specific directory from the archive.

How can I do that?

Best Answer

so, lets back up the directory /directory and everything in it, but ignoring any files called IGNORE-ME.

tar -cf backup.tar /directory --exclude "IGNORE-ME"

If it wasn't snowing out, i'd probably point out that man tar is as good as RTFM (and google 'tar exclude file' is even faster).