0
我確實使用grep很多,但我想提高一點。什麼是最簡單的方法來grep'男人grep'的標誌
關於這個問題。我想縮小man
條目以找出什麼在grep -v 'pattern' filename
的-v
主張的解釋,主要是這樣的:
-v, --invert-match
Selected lines are those not matching any of the specified patterns.
因此,要找到行之後的下一個五行包含-v
我想:
man grep | grep -A 5 -v
和
man grep | grep -A 5 '-v'
但他們返回:
usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]
這讓我困惑,因爲:
man grep | grep -A 5 'Selected'
和
man grep | grep -A 5 Selected
做的工作。
我的方法有什麼問題?有沒有更簡單的方法來實現我所需要的?
有關使用通過它瀏覽'/'其次是你正在尋找的術語是什麼? – fedorqui
我同意上面的搜索形式,但是,您的問題是您的搜索項以連字符開頭,因此grep認爲它是另一種選擇。像許多命令一樣,你可以在正則表達式之前使用2個連字符( - ),這會告訴命令將下一個內容看作文本。你也可以簡單地將連字符轉義(\ - ) – grail
這個Q不是關於爲StackOverflow定義的編程。它可能更適合於S.E.相關網站http://superuser.com或http://unix.stackexchange.com(Unix和Linux)。使用Q底部的'flag'鏈接並請主持人移動它。請不要在2個不同的網站上發佈相同的Q.在此處發佈更多Q值之前,請閱讀http://stackoverflow.com/help/how-to-ask http://stackoverflow.com/help/dont-ask和http://stackoverflow.com/help/mcve。祝你好運。 – shellter