파이프와 대시가 포함된 명령이 정확히 어떻게(그리고 왜) 작동합니까?
pacman -Qqdt | sudo pacman -Rns -
답변1
단일 대시( -
), 옵션 없음,일반적으로 "표준 입력에서 읽음"을 의미합니다.. 이는 많은 프로그램에서 사용되는 매우 일반적인 규칙입니다. 파이프는 |
한 프로그램의 표준 출력을 다른 프로그램의 표준 입력에 연결하는 방법입니다. 기본적으로 표준 입력에서 읽지 않으므로 pacman
그렇게 하려는 경우 를 사용할 수 있습니다 -
.
따라서 표시되는 명령은 다음을 수행합니다( 참조 man pacman
).
pacman -Qqdt
:-Q, --query Query the package database. This operation allows you to view installed packages and their files, as well as meta-information about individual packages (dependencies, conflicts, install date, build date, size). This can be run against the local package database or can be used on individual package files. In the first case, if no package names are provided in the command line, all installed packages will be queried. Additionally, various filters can be applied on the package list. See Query Options below. -q, --quiet Show less information for certain query operations. This is useful when pacman’s output is processed in a script. Search will only show package names and not version, group, and description information; owns will only show package names instead of "file is owned by pkg" messages; group will only show package names and omit group names; list will only show files and omit package names; check will only show pairs of package names and missing files; a bare query will only show package names rather than names and versions. -d, --deps Restrict or filter output to packages installed as dependencies. This option can be combined with -t for listing real orphans - packages that were installed as dependencies but are no longer required by any installed package. -t, --unrequired Restrict or filter output to print only packages neither required nor optionally required by any currently installed package. Specify this option twice to include packages which are optionally, but not directly, required by another package.
이러한 옵션을 결합하면 다음과 같은 의미가 있습니다."다른 패키지의 종속성으로 설치된 패키지에 대한 데이터베이스를 쿼리하여 패키지 이름만 표시하고 현재 설치된 패키지에 필요하지 않은 패키지로 출력을 제한합니다."즉, 다른 것이 필요하기 때문에 설치되었지만 다른 것이 제거되었기 때문에 더 이상 필요하지 않은 패키지를 표시합니다.
sudo pacman -Rns -
:-R, --remove Remove package(s) from the system. Groups can also be specified to be removed, in which case every package in that group will be removed. Files belonging to the specified package will be deleted, and the database will be updated. Most configuration files will be saved with a .pacsave extension unless the --nosave option is used. See Remove Options below. -n, --nosave Instructs pacman to ignore file backup designations. Normally, when a file is removed from the system, the database is checked to see if the file should be renamed with a .pacsave extension. -s, --recursive Remove each target specified including all of their dependencies, provided that (A) they are not required by other packages; and (B) they were not explicitly installed by the user. This operation is recursive and analogous to a backwards --sync operation, and it helps keep a clean system without orphans. If you want to omit condition (B), pass this option twice.
그리고
-
(강조):pacman을 호출하려면 잠재적인 옵션과 작업 대상을 사용하여 작업을 지정해야 합니다. 대상은 일반적으로 패키지 이름, 파일 이름, URL 또는 검색 문자열입니다. 대상은 명령줄 인수로 제공될 수 있습니다. 또한 stdin이 터미널에서 나오지 않고 단일 하이픈(-)이 인수로 전달되는 경우 대상은 stdin에서 읽습니다.
따라서
pacman -Rns -
패키지 이름은 표준 입력에서 읽혀지며 모든 패키지 이름과 해당 종속성은 백업을 유지하지 않고 삭제됩니다.
따라서 전체 명령은 시스템에서 더 이상 필요하지 않은 패키지를 찾아서 제거합니다. 이는 시스템에서 원하지 않는 패키지를 정리하는 유용한 방법입니다.