メモ-コマンド・コマンドオプション-
"--":オプション終端子
前方のコマンドのアプションの終了を伝えて、後方の処理対象をそのまま伝えるもの。
% ls -- <処理対象(オペランド)>
The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character.
直訳
オプション引数ではない最初の「--」引数は、オプションの終わりを示す区切り文字として受け入れられるべきである。それ以降のすべての引数は、たとえ「-」文字で始まっていたとしても、オペランド(処理対象の値)として扱われるべきである。
Utility Conventionspubs.opengroup.org
オプション
ls
ls -l :詳細情報付きで表示
grep
grep コマンドは、「grep のあとに続く文字列を含む行」の検索
$ ps aux | grep nginx
root 475536 0.0 0.1 14908 9132 ? S 07:05 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 475539 0.0 0.0 18252 6968 ? S 07:05 0:00 nginx: worker process
www-data 475540 0.0 0.0 18252 7100 ? S 07:05 0:00 nginx: worker process
www-data 475541 0.0 0.0 18252 6968 ? S 07:05 0:00 nginx: worker process
www-data 475542 0.0 0.0 18252 7488 ? S 07:05 0:00 nginx: worker process
ubuntu 509417 0.0 0.0 6724 1988 pts/0 S+ 12:15 0:00 grep --color=auto nginx
$ ps aux | grep nginx | wc -l
6
``
と、grepした内容も検索に引っかかってしまうことがある(よくある)
これの対策は、
// grep -vオプション:-vは「後ろの文字列を除外」これで、grep自身を除外できる % ps aux | grep nginx | grep -v grep | wc -l 5
// 正規表現の文字クラスを使う % ps aux | grep [n]ginx | wc -l 5
// pgrep :プロセスIDのみを直接検索・表示するコマンド。 // -f :コマンドライン全体を検索対象にする // -l :プロセス名も一緒に表示する % pgrep -fl nginx
## cron
[https://www.kagoya.jp/howto/it-glossary/server/cron/:embed:cite]
-----
はてなブログから移行しました(元の記事)