Yes, it is possible, and simple.
As Hastur mentioned, the command you want is:
tar --exclude='*.pyc' czvf testdir.tgz testdir
And I want to add that if you have a question about any terminal command you are using on Linux (or Mac OS X for that matter), the best place to start is with the official documentation. Type man tar
and you will pull it up. You can search through the man page (manual page) by typing /searchterm
(and n
for next match) and you can scroll through the page using f
and b
, d
and u
, or j
and k
depending on how much you want to scroll in one step.
"But the documentation is decades old in some cases!" Yes, it is...and so are the tools you are using. They have stood the test of time. Really, the man page should always be the FIRST resort if you are having trouble.
Typing man tar
followed by /exclude
yielded:
--exclude=PATTERN
exclude files, given as a PATTERN
tar --exclude='*.pyc' czvf myFile.tgz testdir/*
?