- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章你应该选择 Powershell 的10个理由(抛弃 cmd)由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
Powershell 从 Windows7 时代开始内置于 Windows 系统当中,可以看作是微软对 cmd 的大升级,目前两者并存于 Windows 系统中.
首先强烈推荐一个 powershell 学习网站:
powershell在线教程 。
1. powershell 更加 “powerful” 。
微软起“powershell”这个名字虽然有吹牛逼的嫌疑(我以前也这样想),但从事实来看并非如此。powershell 的强大程度分分钟秒杀 Linux 上的 bash,更不要说饱受诟病的 cmd 了。(无意打广告) 。
2. powershell 全面支持面向对象 。
powershell 背后依靠的是一套完整的 .NET 编程体系,其脚本更容易编写且稳健性大大提升。反过来看 cmd,那些完全由各种命令堆砌而成的一条条指令简直就是“小打小闹”.
3. 从 cmd 迁移到 powershell 成本几乎为零 。
如果你对老朋友 cmd 充满情怀,无法舍弃,完全无妨!因为 powershell 可以看作 cmd 的超集,所有的常用命令诸如dir, cd, ipconfig等在 powershell 中都能直接使用。但背后的实现方式是完全不同的,powershell 基于完全的面向对象,它通过给函数和对象“起别名”的方式来支持这些旧的命令.
4. 诱人的管道操作 。
管道操作的灵感来自 Linux 的 shell,但由于 powershell 将一切都包装成为对象,而不是直接处理字符串,因此其管道操作的灵活程度远在 Linux 的 shell 之上.
例如:
1
2
3
4
5
6
7
8
9
10
11
12
|
PS
C:\Users\Haley>
ls
|
sort
-Descending
Name |
Format-Table
Name,Mode
Name Mode
---- ----
VirtualBox VMs d-----
Videos d
-r
---
Searches d
-r
---
Saved Games d
-r
---
Pictures d
-r
---
OneDrive d
-r
---
Music d
-r
---
Links d
-r
---
|
这条命令列出当前路径下的所有文件,按照名称降序排序,并以表格的形式输出,且只显示Name和Mode两个字段.
5. 绝对完备的帮助文档 。
任何函数与对象都能够通过help *命令来查看其帮助文档(准确来说应该是Get-Help函数,这是更加“面向对象”化的命名方式,而help是它的别名),如果看不明白,加上-examples参数会有应用实例,如果仍看不明白,加上-online参数会打开完整的在线帮助文档,不得不佩服,微软的一条龙服务做的很到位.
例如,关于ls的帮助文档如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
PS C:\Users\Haley> help ls
名称
Get-ChildItem
摘要
Gets the items and child items in one or more specified locations.
语法
Get-ChildItem [[-Filter] <String>] [-Attributes {ReadOnly | Hidden | System | Directory | Archive | Device | Normal
| Temporary | SparseFile | ReparsePoint | Compressed | Offline | NotContentIndexed | Encrypted | IntegrityStream |
NoScrubData}] [-Depth <UInt32>] [-Directory] [-Exclude <String[]>] [-File] [-Force] [-Hidden] [-Include <String[]>
] -LiteralPath <String[]> [-Name] [-ReadOnly] [-Recurse] [-System] [-UseTransaction] [<CommonParameters>]
Get-ChildItem [[-Path] <String[]>] [[-Filter] <String>] [-Attributes {ReadOnly | Hidden | System | Directory | Arch
ive | Device | Normal | Temporary | SparseFile | ReparsePoint | Compressed | Offline | NotContentIndexed | Encrypte
d | IntegrityStream | NoScrubData}] [-Depth <UInt32>] [-Directory] [-Exclude <String[]>] [-File] [-Force] [-Hidden]
[-Include <String[]>] [-Name] [-ReadOnly] [-Recurse] [-System] [-UseTransaction] [<CommonParameters>]
说明
The Get-ChildItem cmdlet gets the items in one or more specified locations. If the item is a container, it gets the
items inside the container, known as child items. You can use the Recurse parameter to get items in all child cont
ainers.
A location can be a file system location, such as a directory, or a location exposed by a different Windows PowerSh
ell provider, such as a registry hive or a certificate store.
相关链接
Online Version: http://go.microsoft.com/fwlink/?LinkId=821580
Get-Item
Get-Location
Get-Process
Get-PSProvider
备注
若要查看示例,请键入: "get-help Get-ChildItem -examples".
有关详细信息,请键入: "get-help Get-ChildItem -detailed".
若要获取技术信息,请键入: "get-help Get-ChildItem -full".
有关在线帮助,请键入: "get-help Get-ChildItem -online"
|
6. 支持基本的数学运算和数组操作(加减乘除模),打开就能当计算器用 。
1
2
3
4
5
6
7
8
9
10
|
PS
C:\Users\Haley> 1 + 1
2
PS
C:\Users\Haley> 3 * 5
15
PS
C:\Users\Haley> 0xab
171
PS
C:\Users\Haley> 1kb
1024
PS
C:\Users\Haley> 1mb / 1kb
1024
|
7. 良好的脚本编程体验 。
powershell 脚本的语法与高级编程语言非常相近,例如其分支语句if(...){} else{}、循环语句for(...){}与 C 语言别无二致,因而大大提高了编程体验.
8. 拥有丰富的字符串操作对象和函数,全面支持正则表达式 。
字符串处理是 shell 脚本的主要任务,正则表达式的重要性也无需多说.
9. 支持重定向,读写文件易如反掌 。
powershell 原生支持将结果导出到html, csv, xml等文件,也可以通过重定向从文件中读取内容.
例如:
1
|
PS
C:\Users\Haley>
ls
|
Select-Object
Mode,Name |
Export-Csv
~/desktop/test.csv
|
这样就把当前目录下的所有 文件名-读写权限 保存到了一个 csv 文件中.
10. 支持 Debug 。
虽然这个功能很少用到,但支持 debug 是走向完备编程语言不可或缺的一项功能.
原文链接:http://www.jianshu.com/p/931ae4c34120 。
最后此篇关于你应该选择 Powershell 的10个理由(抛弃 cmd)的文章就讲到这里了,如果你想了解更多关于你应该选择 Powershell 的10个理由(抛弃 cmd)的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
是否有某种方法可以使用 JPA 或 Hibernate Crtiteria API 来表示这种 SQL?或者我应该将其作为 native 执行吗? SELECT A.X FROM (SELECT X,
在查询中, select id,name,feature,marks from (....) 我想删除其 id 在另一个 select 语句中存在的那些。 从 (...) 中选择 id 我是 sql
我想响应用户在 select 元素中选择一个项目。然而这个 jQuery: $('#platypusDropDown').select(function () { alert('You sel
这个问题在这里已经有了答案: SQL select only rows with max value on a column [duplicate] (27 个回答) 关闭8年前。 我正在学习 SQL
This question already has answers here: “Notice: Undefined variable”, “Notice: Undefined index”, and
我在 php 脚本中调用 SQL。有时“DE”中没有值,如果是这种情况我想从“EN”中获取值 应该是这样的,但不是这样的 IF (EXISTS (SELECT epf_application_deta
这可能是一个奇怪的问题,但不知道如何研究它。执行以下查询时: SELECT Foo.col1, Foo.col2, Foo.col3 FROM Foo INNER JOIN Bar ON
如何在使用 Camera.DestinationType.FILE_URI. 时在 phonegap camera API 中同时选择或拾取多个图像我能够一次只选择一张图像。我可以使用 this 在
这是一个纯粹的学术问题。这两个陈述实际上是否相同? IF EXISTS (SELECT TOP 1 1 FROM Table1) SELECT 1 ELSE SELECT 0 相对 IF EXIS
我使用 JSoup 来解析 HTML 响应。我有多个 Div 标签。我必须根据 ID 选择 Div 标签。 我的伪代码是这样的 Document divTag = Jsoup.connect(link
我正在处理一个具有多个选择框的表单。当用户从 selectbox1 中选择一个选项时,我需要 selectbox2 active 的另一个值。同样,当他选择 selectbox2 的另一个值时,我需要
Acme Inc. Christa Woods Charlotte Freeman Jeffrey Walton Ella Hubbard Se
我有一个login.html其中form定义如下: First Initial Plus Last Name : 我的do_authorize如下: "; pri
$.get( 'http://www.ufilme.ro/api/load/maron_online/470', function(data
我有一个下拉列表“磅”、“克”、“千克”和“盎司”。我想要这样一种情况,当我选择 gram 来执行一个函数时,当我在输入字段中输入一个值时,当我选择 pounds 时,我想要另一个函数来执行时我在输入
我有一个 GLSL 着色器,它从输入纹理的 channel 之一(例如 R)读取,然后写入输出纹理中的同一 channel 。该 channel 必须由用户选择。 我现在能想到的就是使用一个 int
我想根据下拉列表中的选定值生成输入文本框。 Options 2 3 4 5 就在这个选择框之后,一些输入字段应该按照选定的数字出现。 最佳答案 我建议您使用响应式(Reac
我是 SQL 新手,我想问一下如何根据首选项和分组选择条目。 +----------+----------+------+ | ENTRY_ID | ROUTE_ID | TYPE | +------
我有以下表结构: CREATE TABLE [dbo].[UTS_USERCLIENT_MAPPING_USER_LIST] ( [MAPPING_ID] [int] IDENTITY(1,1
我在移除不必要的床单时遇到了问题。我查看了不同的论坛并将不同的解决方案混合在一起。 此宏删除工作表(第一张工作表除外)。 Sub wrong() Dim sht As Object Applicati
我是一名优秀的程序员,十分优秀!