GCI yog dab tsi hauv PowerShell?
GCI yog dab tsi hauv PowerShell?

Video: GCI yog dab tsi hauv PowerShell?

Video: GCI yog dab tsi hauv PowerShell?
Video: PowerShell! Moving Files and Directories 2024, Kaum ib hlis
Anonim

Scripting Cov ntaub ntawv nrog PowerShell's Get-Childitem ( gci ua ) Tsis ntev los sis tom qab koj xav tau ib tsab ntawv uas teev cov ntaub ntawv hauv ib daim nplaub tshev. Hauv DOS peb yuav ntaus: 'DIR'; qhov ze tshaj nyob rau hauv PowerShell yog gci ua . Lub npe tag nrho hauv qab gci ua npe is Tau-ChildItem.

Ntawm no, ChildItem yog dab tsi hauv PowerShell?

Kev piav qhia. The Get- ChildItem cmdlet tau txais cov khoom hauv ib lossis ntau qhov chaw teev tseg. Yog tias cov khoom yog acontainer, nws tau txais cov khoom hauv lub thawv, hu ua cov khoom me me. Cov chaw raug nthuav tawm rau Get- ChildItem los ntawm PowerShell cov neeg muab kev pabcuam.

Tsis tas li ntawd, kuv yuav mus rau ib lub nplaub tshev hauv PowerShell li cas? Qhib Windows PowerShell los ntawm xaiv Pib | Khiav | PowerShell . Qhov rai PowerShell sai opens bydefault ntawm lub hauv paus ntawm koj tus neeg siv nplaub tshev . Hloov mus rau lub hauv paus ntawm C: los ntawm kev nkag mus rau cd c: hauv Windows PowerShell kom sai. Tau txais cov npe ntawm tag nrho cov ntaub ntawv hauv lub hauv paus ntawm C: los ntawm kev siv cov lus txib dir.

Ib yam li ib tug yuav nug, $ _ hauv PowerShell yog dab tsi?

$_ sawv cev rau cov khoom tam sim no ntawm lub raj xa dej– yog tias koj xav paub vim li cas $_ tau xaiv koj yuav tau nyeem PowerShell hauv Action! Rau recap $_ (los yog $psitem) yog siv los sawv cev rau cov khoom tam sim no ntawm cov kav dej. Koj tuaj yeem siv cov lus txib uas ua haujlwm ntawm txhua yam khoom ntawm cov kav dej.

Recurse ua dab tsi hauv PowerShell?

Cov ntsiab lus ntawm PowerShell - Rov qab los - Rov qab los yog ib tug classic hloov, uas qhia PowerShell cov lus txib xws li Get-ChildItem rov ua dua hauv subdirectories. Thaum koj nco qab tias - Rov qab los los ncaj qha tom qab cov ntawv teev npe, tom qab ntawd nws yuav ua haujlwm zoo rau koj hauv cov ntawv sau uas xav tau los mus nrhiav cov ntaub ntawv.

Pom zoo: