awk應用2:列出本目錄下所有的隱藏文件和目錄

想要實現一個小功能,顯示本目錄下所有的隱藏文件和目錄。

[root@localhost root]# ll -a|awk '$9~/^/./ {print}'

drwxr-x---   14 root     root         4096 Apr 21 18:32 .

drwxr-xr-x   19 root     root         4096 Mar 22 12:20 ..

-rw-------    1 root     root         7962 Apr 21 18:38 .bash_history

-rw-r--r--    1 root     root           24 Jun 10  2000 .bash_logout

-rw-r--r--    1 root     root          234 Jul  5  2001 .bash_profile

-rw-r--r--    1 root     root          176 Aug 23  1995 .bashrc

-rw-r--r--    1 root     root          210 Jun 10  2000 .cshrc

-rw-------    1 root     root           16 Mar 26 13:50 .esd_auth

-rw-r--r--    1 root     root           51 Apr 15 18:31 .fonts.cache-1

drwx------    4 root     root         4096 Mar 23 17:47 .gconf

drwx------    2 root     root         4096 Mar 23 17:47 .gconfd

drwx------    5 root     root         4096 Mar 22 06:36 .gnome

drwxr-xr-x    7 root     root         4096 Mar 23 17:45 .gnome2

drwx------    2 root     root         4096 Mar 22 06:36 .gnome2_private

drwxr-xr-x    2 root     root         4096 Mar 22 12:13 .gnome-desktop

drwxr-xr-x    2 root     root         4096 Mar 22 06:11 .gstreamer

-rw-r--r--    1 root     root          120 Aug 20  2003 .gtkrc

-rw-r--r--    1 root     root          130 Mar 22 06:36 .gtkrc-1.2-gnome2

-rw-------    1 root     root            0 Mar 22 12:13 .ICEauthority

drwx------    3 root     root         4096 Mar 22 06:36 .metacity

drwxr-xr-x    3 root     root         4096 Mar 25 18:38 .mozilla

drwxr-xr-x    3 root     root         4096 Mar 22 06:36 .nautilus

-rw-------    1 root     root          359 Mar 22 12:01 .recently-used

-rw-------    1 root     root          497 Mar 22 06:36 .rhn-applet.conf

-rw-------    1 root     root         1024 Mar 26 16:02 .rnd

drwx------    2 root     root         4096 Mar 28 08:47 .ssh

-rw-r--r--    1 root     root          196 Jul 11  2000 .tcshrc

-rw-------    1 root     root         4400 Apr 21 18:32 .viminfo

-rw-------    1 root     root         5139 Apr 21 18:08 .viminfo.tmp

-rw-------    1 root     root          134 Apr 21 15:51 .Xauthority

-rw-r--r--    1 root     root         1126 Aug 23  1995 .Xresources

-rw-------    1 root     root          580 Mar 22 12:13 .xsession-errors

 

$9~/^/./

$9:表示ll –a顯示結果的第九列

~:規則表達式用匹配的運算符。

/.:.開頭的字符串,在Linux中表示隱藏文件或目錄。

//:/中間的內容就是規則表達式的內容。

發佈了13 篇原創文章 · 獲贊 0 · 訪問量 19萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章