Friday, September 28, 2012

How to list only hidden files in UNIX?

ls -1A | grep '^\.'

Eg:


[vjsujay@cheetah:/home/vjsujay]#ls -1A | grep '^\.'
.profile
.recently-used
.sh_history
.softwareupdate
.ssh
[vjsujay@cheetah:/home/vjsujay]#

[vjsujay@cheetah:/home/vjsujay]#ls -1a | grep '^\.'
.
..
.profile
.recently-used
.sh_history
.softwareupdate
.ssh
[vjsujay@cheetah:/home/vjsujay]#


FYI.

-a will list hidden files along with default directories single dot(.) and double-dot(..)
-A will list hidden files without single dot and double dot

2 comments:

BharathKumarRaju Dasararaju said...

Thanks thala ...> $ls -la | grep '\.' (or) $ls -lA | grep '\.' which can lists the hidden files full list as well.

bharath@bharathsolaris:~$ ls -lA | grep '\.'
drwx------ 2 bharath staff 3 Nov 17 22:32 .audioctl
-rw------- 1 bharath staff 9312 Dec 28 23:09 .bash_history
-rw-r--r-- 1 bharath staff 159 Nov 17 12:42 .bashrc
drwx------ 3 bharath staff 3 Dec 24 13:09 .cache
drwxr-xr-x 5 bharath staff 8 Nov 17 13:32 .config
drwx------ 3 bharath staff 3 Nov 17 12:59 .dbus
drwx------ 2 bharath staff 3 Dec 28 05:19 .dbus-keyrings
-rw-r--r-- 1 bharath staff 4277 Dec 22 11:47 .dircolorsrc
-rw-r--r-- 1 bharath staff 42 Dec 29 11:26 .dmrc
drwx------ 4 bharath staff 4 Dec 29 11:26 .gconf
drwx------ 2 bharath staff 3 Dec 29 13:25 .gconfd
drwx------ 7 bharath staff 8 Dec 15 19:02 .gnome2
drwx------ 2 bharath staff 2 Nov 17 12:59 .gnome2_private
drwx------ 2 bharath staff 3 Nov 17 20:04 .gphoto
drwxr-xr-x 2 bharath staff 3 Nov 17 12:59 .gstreamer-0.10
-rw-r--r-- 1 bharath staff 177 Dec 29 11:26 .gtk-bookmarks
-rw-r--r-- 1 bharath staff 0 Dec 22 11:58 .hushlogin
-rw------- 1 bharath staff 4200 Dec 29 11:26 .ICEauthority
drwxr-xr-x 2 bharath staff 2 Nov 17 13:17 .icons
drwxr-xr-x 3 bharath staff 3 Nov 17 20:06 .java
-rw------- 1 bharath staff 39 Dec 29 12:44 .lesshst
drwx------ 3 bharath staff 3 Nov 17 12:59 .local
drwx------ 4 bharath staff 4 Nov 25 17:05 .mozilla
drwxr-xr-x 2 bharath staff 2 Nov 17 12:59 .nautilus
-rw-r--r-- 1 bharath staff 591 Dec 25 16:04 .profile
drwx------ 6 bharath staff 12 Dec 29 13:27 .purple
-rw------- 1 bharath staff 218 Dec 15 19:02 .recently-used.xbel
drwx------ 2 bharath staff 3 Dec 8 22:38 .ssh
drwxr-xr-x 2 bharath staff 2 Nov 17 13:17 .themes
drwx------ 3 bharath staff 3 Nov 17 13:17 .thumbnails
drwx------ 3 bharath staff 5 Nov 17 23:26 .thunderbird
drwxr-xr-x 3 bharath staff 3 Nov 17 13:09 .updatemanager
drwxr-xr-x 2 bharath staff 6 Dec 29 11:27 .vp
-rw-r--r-- 1 bharath staff 8509 Nov 17 13:16 .xscreensaver
-rw------- 1 bharath staff 3001 Dec 29 11:45 .xsession-errors
-rw------- 1 bharath staff 4673 Dec 28 23:09 .xsession-errors.old

BharathKumarRaju Dasararaju said...

[bharath@localhost ~]$ ls -lad .*
drwx------. 32 bharath bharath 4096 Mar 16 13:13 .
drwxr-xr-x. 3 root root 4096 Mar 8 14:03 ..
-rw-------. 1 bharath bharath 2903 Mar 15 11:27 .bash_history
-rw-r--r--. 1 bharath bharath 18 Jun 22 2010 .bash_logout
-rw-r--r--. 1 bharath bharath 171 Mar 8 10:22 .bash_profile
-rw-r--r--. 1 bharath bharath 124 Jun 22 2010 .bashrc
drwxr-xr-x. 3 bharath bharath 4096 Mar 15 10:47 .cache
drwxr-xr-x. 5 bharath bharath 4096 Mar 8 09:51 .config
drwx------. 3 bharath bharath 4096 Mar 8 08:37 .dbus
-rw-r--r--. 1 bharath bharath 41 Mar 16 13:13 .dmrc
-rw-------. 1 bharath bharath 16 Mar 8 08:37 .esd_auth
drwxrwxr-x. 3 bharath bharath 4096 Mar 8 09:51 .evolution
-rw-r--r--. 1 bharath bharath 23320 Mar 8 09:51 .face
drwxr-xr-x. 2 bharath bharath 4096 Mar 8 08:37 .fontconfig
drwx------. 4 bharath bharath 4096 Mar 16 13:13 .gconf
drwx------. 2 bharath bharath 4096 Mar 16 13:33 .gconfd
drwxr-xr-x. 8 bharath bharath 4096 Mar 15 01:14 .gnome2
drwx------. 2 bharath bharath 4096 Mar 10 12:43 .gnome2_private
drwxrwxr-x. 3 bharath bharath 4096 Mar 8 08:37 .gnote
drwx------. 2 bharath bharath 4096 Mar 16 13:13 .gnupg
drwxrwxr-x. 2 bharath bharath 4096 Mar 8 08:37 .gstreamer-0.10
-rw-rw-r--. 1 bharath bharath 147 Mar 16 13:13 .gtk-bookmarks
drwx------. 2 bharath bharath 4096 Mar 8 08:37 .gvfs
-rw-------. 1 bharath bharath 2480 Mar 16 13:13 .ICEauthority
drwxrwxr-x. 2 bharath bharath 4096 Mar 8 08:38 .icons
drwxr-xr-x. 3 bharath bharath 4096 Mar 8 08:37 .local
drwxr-xr-x. 5 bharath bharath 4096 Mar 10 12:43 .mozilla
drwxr-xr-x. 2 bharath bharath 4096 Mar 8 08:37 .nautilus
drwx------. 2 bharath bharath 4096 Mar 8 08:37 .pulse
-rw-------. 1 bharath bharath 256 Mar 8 08:37 .pulse-cookie
-rw-------. 1 bharath bharath 842 Mar 15 11:27 .recently-used.xbel
drwx------. 2 bharath bharath 4096 Mar 8 08:37 .ssh
drwxrwxr-x. 2 bharath bharath 4096 Mar 8 08:38 .themes
drwx------. 4 bharath bharath 4096 Mar 8 08:38 .thumbnails
-rw-------. 1 bharath bharath 3391 Mar 15 00:56 .viminfo
-rw-------. 1 bharath bharath 600 Mar 16 13:13 .xsession-errors
-rw-------. 1 bharath bharath 2628 Mar 15 11:27 .xsession-errors.old