여러 lsof 옵션 결합

여러 lsof 옵션 결합

-i-p옵션을 lsof논리적 연결로 결합할 수 있는 방법이 있습니까 ? 기본 동작은 하나 또는 다른 조건을 충족하는 파일을 표시하는 것 같은데, 조금 이상하다고 생각합니다.

답변1

-a표시된 옵션 중 하나를 사용하세요 .lsof매뉴얼 페이지의 예:

To list all open IPv4 network files in use by the process whose
PID is 1234, use:

       lsof -i 4 -a -p 1234

이것"옵션" 섹션설명하다:

Normally list options that are specifically stated are ORed -
i.e., specifying the -i option without an address and the -ufoo
option produces a listing of all network files OR files belonging
to processes owned by user ``foo''.  The exceptions are:

[…]

The -a option may be used to AND the selections.  For example,
specifying -a, -U, and -ufoo produces a listing of only UNIX
socket files that belong to processes owned by user ``foo''.

Caution: the -a option causes all list selection options to be
ANDed; it can't be used to cause ANDing of selected pairs of
selection options by placing it between them, even though its
placement there is acceptable.  Wherever -a is placed, it causes
the ANDing of all selection options.

Items of the same selection set - command names, file
descriptors, network addresses, process identifiers, user
identifiers, zone names, security contexts - are joined in a
single ORed set and applied before the result participates in
ANDing.  Thus, for example, specifying [email protected], [email protected],
-a, and -ufff,ggg will select the listing of files that belong to
either login ``fff'' OR ``ggg'' AND have network connections to
either host aaa.bbb OR ccc.ddd.

[…]

-a     causes list selection options to be ANDed, as described
       above.

관련 정보