반응형
파워셸: Get-Item vs Get-ChildItem
나는 다음의 차이점을 이해하고 싶습니다.Get-Item
그리고.Get-ChildItem
. 한 가지 예로 가능한 경우.
Get-Item
지정한 위치에서 항목을 가져옵니다.
Get-Item .\foo
# returns the item foo
Get-Child 항목
하나 이상의 지정된 위치에 있는 항목 및 하위 항목을 가져옵니다.
Get-ChildItem .\foo
# returns all of the children within foo
참고: Get-ChildItem은 자식 디렉토리로 반복될 수도 있습니다.
Get-ChildItem .\foo -Recurse
# returns all of the children within foo AND the children of the children
만약 당신이 이런 폴더를 가지고 있다면.
Folder
├─ File-A
└─ File-B
- 아이템이 폴더일 경우,
Get-ChildItem
항목의 자식을 반환합니다.
Get-Item Folder
# Folder
Get-ChildItem Folder
# File-A File-B
- 항목이 폴더가 아닌 경우,
Get-ChildItem
아이템을 반환합니다.
Get-Item Folder\File-A
# File-A
Get-ChildItem Folder\File-A
# File-A
현재 디렉터리 가져오기
Get-Item .
현재 디렉터리에 있는 모든 항목 가져오기
# use Get-Item
Get-Item *
# or use Get-ChildItem
Get-ChildItem
모든 txt 파일 가져오기
# use Get-Item
Get-Item *.txt
# or use Get-ChildItem
Get-ChildItem *.txt
참조:
언급URL : https://stackoverflow.com/questions/38663391/powershell-get-item-vs-get-childitem
반응형
'sourcetip' 카테고리의 다른 글
PowerShell로 이메일 보내는 방법 (0) | 2023.11.04 |
---|---|
CSS to set A4 paper size (0) | 2023.11.04 |
PHP PDO 및 MySQLi (0) | 2023.11.04 |
jQuery 플러그인을 확장하는 가장 좋은 방법 (0) | 2023.11.04 |
XML에서 "xmlns"는 무엇을 의미합니까? (0) | 2023.11.04 |