|
|
发表于 2005-4-8 00:19:11
|
显示全部楼层
Post by aaccdd
隐藏目录
ls -Ap|sed -ne '/^\..*\/$/p' 或 ls -AF|grep -e "^\..*/$"
但是隐藏文件 ls -AF|grep -ve "/$" 是有问题的
这个好像可以
ls -Ap|grep -e "^\..*[^/]$"
这次都对了
- zhyfly@zhyfly:~$ ls -Ap
- bash/ .gnome/ .nautilus/
- .bash_history .gnome2/ orderwiz.ami
- .bash_profile .gnome2_private/ .recently-used
- .bashrc .gstreamer-0.8/ .thumbnails/
- Desktop/ .gtkrc-1.2-gnome2 ttf-fireflysung_1.0.0-1_i386.deb
- .dmrc .ICEauthority .viminfo
- .fcitx/ Linux命令大全.chm .Xauthority
- .fonts.cache-1 mbox .xsession-errors
- .gconf/ .metacity/
- .gconfd/ .mozilla/
- zhyfly@zhyfly:~$ ls -Ap|grep -e '^\..*[^/]$'
- .bash_history
- .bash_profile
- .bashrc
- .dmrc
- .fonts.cache-1
- .gtkrc-1.2-gnome2
- .ICEauthority
- .recently-used
- .viminfo
- .Xauthority
- .xsession-errors
- zhyfly@zhyfly:~$
复制代码但是隐藏文件 ls -AF|grep -ve "/$" 是有问题的
是的,- zhyfly@zhyfly:~$ ls -Ap|grep -ve "/$"
- .bash_history
- .bash_profile
- .bashrc
- .dmrc
- .fonts.cache-1
- .gtkrc-1.2-gnome2
- .ICEauthority
- [b]Linux命令大全.chm[/b]
- [b]mbox[/b]
- [b]orderwiz.ami[/b]
- .recently-used
- [b]ttf-fireflysung_1.0.0-1_i386.deb[/b]
- .viminfo
- .Xauthority
- .xsession-errors
复制代码
其中- -v, --invert-match
- Invert the sense of matching, to select non-matching lines.
复制代码 可见,-v选项是相反匹配,只要不是以/结尾就满足,而非隐藏文件就也满足这个要求,所以不对,改正以后的对了. |
|