Home » Linux Basics » Linux: Bash Find Matching All Dot Files

Linux: Bash Find Matching All Dot Files

A dot-file is generally any file whose name begins with a full stop. In Linux it is also called as hidden file. How do I list all dot files in my home directory?

You can use the ls command to list all dot files in your current directory:

 
ls  .*

Sample outputs:

.bash_history  .bash_profile  .bashrc  .lesshst  .profile  .viminfo
.:
checkfs  checkroot  interfaces	interfaces.new	scripts  securedata.keyfile
..:
lost+found  root  root.user.only
.aptitude:
cache  config
.keychain:
nas01-csh  nas01-fish  nas01-sh
.ssh:
id_rsa	id_rsa.pub  known_hosts
.system_file_bakups:
.vim:

Another option is to use the find command:
$ find . -name ".*"
Sample outputs:

.
./.bash_history
./.system_file_bakups
./.viminfo
./.bashrc
./.lesshst
./.ssh
./.profile
./.aptitude
./.bash_profile
./.vim
./.vim/.netrwhist
./.keychain

To list only matching dot files, enter:
$ find . -type f -name ".*"
Sample outputs:

./.bash_history
./.viminfo
./.bashrc
./.lesshst
./.profile
./.bash_profile
./.vim/.netrwhist

To list only matching dot directories, enter:
$ find . -type d -name ".*"
Sample outputs:

.
./.system_file_bakups
./.ssh
./.aptitude
./.vim
./.keychain

Originally posted 2016-03-05 01:32:24.

About admin

I have been working with Linux based systems since 2002. I hope the article published on this site will be useful to those new to server administration.