Skip to content

Zeroplex 生活隨筆

軟體開發和生活瑣事

小 縮小字型大小。 中 重設字型大小。 大 放大字型大小。

標籤: Linux

在 grep 搜尋「-」符號

Posted on 2014 年 1 月 15 日2021 年 3 月 12 日 By 日落 在〈在 grep 搜尋「-」符號〉中尚無留言

用 grep 搜尋檔案中出現的文字,通常會這樣寫:

$ grep STR fileToSeatch

不過當要搜尋的字串有特出符號,像是「-」,就會出現錯誤訊息:

$ grep "->getVal()" *
grep: invalid option -- '>'

原因是 grep 將「-」開頭的字串視為命令選項 (command option),去尋找「>get()」這個選項,而這個選項並不存在,所以導致錯誤。

在命令輸入前加上「–」,表示之後的參數都當作一般輸入而非選項 (end of option):

$ grep -- "->getVal()" *

要搜尋的字串,就算沒有空白,也建議用引號括起來。像是「>」、「&」等,沒加上引號會在 bash 解析時就發生錯誤:

$ grep > *  # shoud be: grep ">" *
bash: *: ambiguous redirect
Tags:Bash, Linux

GNU screen Session Rename

Posted on 2014 年 1 月 8 日2021 年 3 月 12 日 By 日落 在〈GNU screen Session Rename〉中尚無留言

screen 可以在建立時,為 session 命名:

$ screen -S name

若日後需要修改名稱,可以先 attach session 以後,按下 C-a,在輸入指令:

:sessionname newName

之後 screen -r 就可以看到新的名稱。

Tags:Linux

GNU screen 交換 window 順序

Posted on 2013 年 12 月 19 日2021 年 3 月 12 日 By 日落 在〈GNU screen 交換 window 順序〉中尚無留言

若要交換 window 1 和 window 5 的順序,先 focus 到 window 1,再進入指令模式:

C-a :number 5

windows 1 和 windows 5 的順序便會對調。

Tags:Linux, 資訊學習

Unlock screen (terminal screen manager)

Posted on 2013 年 12 月 5 日2021 年 3 月 12 日 By 日落 在〈Unlock screen (terminal screen manager)〉中尚無留言

手殘常常不小心按到其他按鍵 (該說鍵盤太好按嗎?),而 terminal 就突然沒有反應了。以前的解法是先 terminate 以後,用 screen detach 再 attach。

今天才發現 screen 有個畫面鎖定的功能:

C-a C-x     (lockscreen)  Lock this terminal.

lock 以後,可以用 ^Q 或是 ^A^Q unlock。

Ref:
http://stackoverflow.com/questions/70614/gnu-screen-survival-guide

Tags:Linux

Redmine 連 Postfix 失敗

Posted on 2013 年 11 月 1 日2021 年 3 月 12 日 By 日落 在〈Redmine 連 Postfix 失敗〉中尚無留言

Redmine server 一直沒辦法寄出異動通知,Redmine log 有記錄寄信,但沒有錯誤訊息。後來發現 Postfix log 出現一些奇怪的字樣:

postfix/smtpd[31217]: connect from localhost[127.0.0.1]
postfix/smtpd[31217]: lost connection after STARTTLS from localhost[127.0.0.1]
postfix/smtpd[31217]: disconnect from localhost[127.0.0.1]

查了一下,是因為 Postfix 檢查 TLS 失敗,所以沒辦法寄信。把 TLS 關閉即可。

/etc/postfix/main.cf:

smtpd_use_tls=no

Reference:

Problem using TLS: lost connection after STARTTLS
http://postfix.1071664.n5.nabble.com/Problem-using-TLS-lost-connection-after-STARTTLS-td58911.html

Tags:Linux, Postfix, Redmine

文章分頁

上一頁 1 ... 23 24 25 ... 33 下一頁

其他

關於我  (About me)

  文章 RSS Feed

  留言 RSS Feed

Apache AWS Bash C/C++ Docker FreeBSD GCP Git Google Java JavaScript Laravel Linux Microsoft MSSQL MySQL Nginx PHP PHPUnit PostgreSQL Python Qt Raspberry Pi Ubuntu Unix Vim Web Windows XD 作業系統 分享 好站推薦 專題 攝影 新奇搞笑 新聞 旅遊 生活雜記 程式設計 網路架站 網頁設計 資訊學習 資訊安全 遊戲 音樂


創用 CC 授權條款
本著作係採用創用 CC 姓名標示-相同方式分享 4.0 國際 授權條款授權.