PowerShell是一个跨平台的(Windows,Linux和OSX)自动化和配置工具(框架),可以和已有的工具友好集成,特别优化用于处理结构化数据(如JSON,CSV,XML等),RESTAPIs以及对象模型。它包含一个命令行Shell、一个关联的脚本语言以及一个用于处理cmdlets的框架。
PowerShell就相当于Linux下的Bash以及SHELL脚本编程语言。
PowerShell与Bash的对别:
BashPowerShellDescriptionlsdir,Get-ChildItemListfilesandfolderstreedir-RecurseListallfilesandfolderscdcd,Set-LocationChangedirectorypwdpwd,$pwd,Get-LocationShowworkingdirectoryclear,Ctrl+L,resetcls,clearClearscreenmkdirNew-Item-ItemTypeDirectoryCreateanewfoldertouchtest.txtNew-Item-Pathtest.txtCreateanewemptyfilecattest1.txttest2.txtGet-Contenttest1.txt,test2.txtDisplayfilescontentscp./source.txt./dest/dest.txtCopy-Itemsource.txtdest/dest.txtCopyafilecp-r./source./destCopy-Item./source./dest-RecurseRecursivelycopyfromonefoldertoanothermv./source.txt./dest/dest.txtMove-Item./source.txt./dest/dest.txtMoveafiletootherfolderrmtest.txtRemove-Itemtest.txtDeleteafilerm-r<folderName>Remove-Item<folderName>-RecurseDeleteafolderfind-namebuild*Get-ChildItembuild*-RecurseFindafileorfolderstartingwith'build'grep-Rin"sometext"--include="*.cs"Get-ChildItem-Recurse-Filter*.cs|Select-String-Pattern"sometext"Recursivelycase-insensitivesearchfortextinfiles
评论