Exercise 1 开始
运行PowerShell;
记忆基本指令。
Exercise 2 打印当前工作目录
PS C:\Users\User> pwd
Exercise 3 如果你迷路了...
先打印出当前工作目录,然后返回home directory
PS C:\Users\User>pwd
Path
-----
C:\Users\User
PS C:\Users\User>cd ~
Exercise 4 创建一个新目录
>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 复制文件
>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 移动文件
>cd temp
>mv awesome.txt uncool.txt
>ls
>mv newplace oldplace
>ls
>mv oldplace newplace
>ls newplace
>ls
Exercise 12 查看文件
首先在桌面创建一个test.txt文件,用Notepad++编辑器随便写点内容,然后copy到temp文件夹
>cd temp
>more test.txt
Exercise 13 输出文件
创建一个新文件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的相关链接:
用户手册 : 右键-PowerShell帮助
使用技巧 : http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7097
PowerShell大师 : http://powershell.com/cs/blogs/ebook/default.aspx