How do I tar dot files but not dot directories

Posted by bjackfly on Super User See other posts from Super User or by bjackfly
Published on 2013-08-22T06:09:57Z Indexed on 2013/10/28 3:58 UTC
Read the original article Hit count: 355

Filed under:
|
|

The following tar command will exclude all dot files and dot directories.

tar -cvzf /media/bjackfly/bkup/bkup.gz --exclude '.*' --one-file-system /home/bjackfly

In my case I want the dot files to be backed up in the home directory (.vimrc, .bashrc) etc. but not the dot directories /.config /.cache /.eclipse etc.

Any Linux gurus with a command for this, or do I need to run a find into a tar or do two different tar commands which is non-ideal? One for dot files in the home directory and one for everything else?

© Super User or respective owner

Related posts about linux

Related posts about bash