Frederik DeweerdtFrederik Deweerdt has given a solution that works on GNU tar (used on Linux, Cygwin, FreeBSD, OSX, possibly others), but not on other systems such as NetBSD, OpenBSD or Solaris.
POSIX doesn't specify the tar
command (because it varies too wildly between unix variants) and introduces the pax
command instead. The option -w
means to produce an archive (-r
extracts), and -x
selects the archive format. The option -s '!BRE!!'
excludes all files whose path matches the basic regular expression BRE.
pax -w -x ustar -s '!^.*/\..*$!!' calendar_final >calendar_final.tar