iT邦幫忙

0

redhat下的awk使用

匿名 2013-12-06 17:48:462358 瀏覽
  • 分享至 

  • xImage

有一個資料夾內容如下
-rw-r--r--. 1 root root 42048 Apr 18 2011 install.log
-rw-r--r--. 1 root root 11411 Apr 18 2011 install.log.syslog
drwxr-xr-x. 2 root root 4096 Jul 29 11:55 Lab1
drwxr-xr-x. 2 root root 4096 Jul 30 14:20 Lab4
drwxr-xr-x. 5 root root 4096 Dec 6 10:44 materials
drwxr-xr-x. 2 root root 4096 Dec 4 21:22 Music

如題下方,我想要用awk撈出 Apr 18(即4/18)的資料
希望可以只show出
-rw-r--r--. 1 root root 42048 Apr 18 2011 install.log
-rw-r--r--. 1 root root 11411 Apr 18 2011 install.log.syslog

搭配awk,請問我該如何下?

感恩

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

10
wiseguy
iT邦超人 1 級 ‧ 2013-12-06 18:08:11
最佳解答
<pre class="c" name="code">ls -al | awk '/Apr 18/{print $0}'

就醬。
不過這用 awk 也太大材小用了,用 grep 就行了

<pre class="c" name="code">ls -al | grep -F 'Apr 18'
匿名 檢舉

ls -al | grep -F 'Dec 06'
請問大大
我剛剛用你這行ls -al | grep -F 'Apr 18'
可以成功撈出來

但是我用你這行改成ls -al | grep -F 'Dec 6'
就沒有反應了??

請問我哪邊有怪怪嗎?
感恩

匿名 檢舉

感恩大大
我知了
我少打一個空白鍵
T_T

8
fillano
iT邦超人 1 級 ‧ 2013-12-06 18:06:15

先用grep吧...

我要發表回答

立即登入回答