- 論壇徽章:
- 0
|
本帖最后由 wwr 于 2014-02-03 22:15 編輯
我想通過grep篩選指定關(guān)鍵字符的文件:ch01,ch02,wch01- [root@butter awk]# ll
- total 24
- -rwxr--r-- 1 root root 159 Dec 3 16:36 byState
- -rw-r--r-- 1 root root 60 Feb 3 21:37 ch01
- -rw-r--r-- 1 root root 62 Feb 3 21:42 ch02
- -rw-r--r-- 1 root root 66 Feb 3 21:44 ch03
- -rw-r--r-- 1 root root 342 Jan 29 21:55 list
- -rw-r--r-- 1 root root 101 Dec 3 16:34 nameState
- -rw-r--r-- 1 root root 42 Feb 3 21:45 wch01
復(fù)制代碼 無論嘗試怎么么做,都沒有任何反饋- [root@butter awk]# ll|awk '{print $9}'|grep ch0[12]
- [root@butter awk]# ll|grep ch0[12]
復(fù)制代碼 即使把grep替換成egrep
后來我又用awk的篩選功能,居然發(fā)現(xiàn)成功了:- [root@butter awk]# ll|awk '/ch0[12]/ {print}'
- -rw-r--r-- 1 root root 60 Feb 3 21:37 ch01
- -rw-r--r-- 1 root root 62 Feb 3 21:42 ch02
- -rw-r--r-- 1 root root 42 Feb 3 21:45 wch01
復(fù)制代碼 RHEL6.3 求解釋…… |
|