Linux
打開手冊頁並在單個命令中搜尋字元串
與其做
man chmod
然後/a+x
跳轉到 chmod 手冊頁中提到的第一部分a+x
,我想知道是否有辦法將手冊頁打開到特定的搜尋字元串,類似於vi +string filename.txt
在 vi(m )。
試試這個技巧:
man chmod | less +'/a\+x'
或者
man chmod | more +'/a\+x'
符號前有一個反斜杠,
+
因為後面/
是一個擴展的正則表達式。
據我所知(但正如@sputnick指出的那樣,我知道的不多),但您可以解析它:
man chmod | grep -C 5 'a+x'
我建議使用手冊頁中實際存在的字元串,例如:
$ man chmod | grep -C 5 set-user-ID traversals. SETUID AND SETGID BITS chmod clears the set-group-ID bit of a regular file if the file's group ID does not match the user's effective group ID or one of the user's supplementary group IDs, unless the user has appro‐ priate privileges. Additional restrictions may cause the set-user-ID and set-group-ID bits of MODE or RFILE to be ignored. This behavior depends on the policy and functionality of the under‐ lying chmod system call. When in doubt, check the underlying system behavior. chmod preserves a directory's set-user-ID and set-group-ID bits unless you explicitly specify oth‐ erwise. You can set or clear the bits with symbolic modes like u+s and g-s, and you can set (but not clear) the bits with a numeric mode. RESTRICTED DELETION FLAG OR STICKY BIT The restricted deletion flag or sticky bit is a single bit, whose interpretation depends on the