"Learn Python the Hard Way"學(xué)習(xí)筆記1——快速掌握PowerShell

Exercise 1 開始

運(yùn)行PowerShell;
記憶基本指令。

Exercise 2 打印當(dāng)前工作目錄

PS C:\Users\User> pwd

Exercise 3 如果你迷路了...

先打印出當(dāng)前工作目錄,然后返回home directory

PS C:\Users\User>pwd

Path
-----
C:\Users\User
PS C:\Users\User>cd ~

Exercise 4 創(chuàng)建一個(gè)新目錄

>pwd
>cd ~
>mkdir temp
>mkdir temp/stuff
>mkdir temp/stuff/things
>mkdir temp/stuff/things/frank/joe/alex/john

Exercise 5 改變工作目錄

>cd temp
>pwd
>cd stuff
>pwd
>cd things
>pwd
>cd frank
>pwd
>cd joe
>pwd
>cd alex
>pwd
>cd john
>pwd
>cd ..
>cd ..
>cd ..
>pwd
>cd ../..
>pwd
>cd ..
>cd ..
>cd temp/stuff/things/frank/joe/alex/john
>cd ../../../../../../../
>pwd

Exercise 6 列出目錄中的文件

>cd temp
>ls
>cd stuff
>ls
>cd things
>ls
>cd frank
>ls
>cd joe
>ls
>cd alex
>ls
>cd john
>ls
>cd ..
>ls
>cd ..
>ls
>cd ../../..
>ls
>cd ..

Exercise 7 刪除空目錄

>cd temp
>ls
>cd stuff/things/frank/joe/alex/john/
>cd ..
>rmdir john
>cd ..
>rmdir alex
>cd ..
>rmdir joe
>cd ..
>rmdir frank
>cd ..
>ls
>rmdir things
>cd ..
>ls
>rmdir stuff
>pwd
>cd ..

Exercise 8 到處逛逛:)

>cd temp
>mkdir -p i/like/douban
>pushd i/like/douban
>popd
>pwd
>pushd i/like
>pwd
>pushd douban
>pwd
>popd
>pwd
>popd

Exercise 9 建立空文件

>cd temp
>New-Item iamcool.txt -type file
>ls

Exercise 10 復(fù)制文件

>cd temp
>cp iamcool.txt neat.txt
>ls
>cp neat.txt awesome.txt
>ls
>cp awesome.txt thefourthfile.txt
>ls
>mkdir something
>cp awesome.txt something/
>ls
>ls something
>cp -recurse something newplace
>ls newplace

Exercise 11 移動(dòng)文件

>cd temp
>mv awesome.txt uncool.txt
>ls
>mv newplace oldplace 
>ls
>mv oldplace newplace
>ls newplace
>ls

Exercise 12 查看文件

首先在桌面創(chuàng)建一個(gè)test.txt文件,用Notepad++編輯器隨便寫點(diǎn)內(nèi)容,然后copy到temp文件夾

>cd temp
>more test.txt

Exercise 13 輸出文件

創(chuàng)建一個(gè)新文件test2.txt,直接保存到temp文件夾

>more test2.txt
>cat test2.txt
>cat test.txt

Exercise 14 刪除文件

>cd temp
>ls
>rm uncool.txt
>ls
>rm iamcool.txt
>rm neat.txt
>rm thefourthfile.txt
>ls
>cp -r something newplace
>rm something/awesome.txt
>rmdir something
>rm -r newplace
>ls

Exercise 15 退出終端

>exit

Next Steps

PowerShell的相關(guān)鏈接:
用戶手冊(cè) : 右鍵-PowerShell幫助
使用技巧 : http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7097
PowerShell大師 : http://powershell.com/cs/blogs/ebook/default.aspx

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容